Commit 2e7f3ec5 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCLibrary.m: Regroup the sharedLibrary allocation and...

MacOSX/Framework/VLCLibrary.m: Regroup the sharedLibrary allocation and release. Fix a warning due to a left over in previous commit.
parent 0e514bd7
...@@ -42,14 +42,14 @@ void __quit_on_exception( void * e, const char * function, const char * file, in ...@@ -42,14 +42,14 @@ void __quit_on_exception( void * e, const char * function, const char * file, in
} }
} }
static void *DestroySharedLibraryAtExit() static void * DestroySharedLibraryAtExit( void )
{ {
/* Release the global object that may have been alloc-ed /* Release the global object that may have been alloc-ed
* in -[VLCLibrary init] */ * in -[VLCLibrary init] */
[sharedLibrary release]; [sharedLibrary release];
sharedLibrary = nil; sharedLibrary = nil;
return nil; return NULL;
} }
@implementation VLCLibrary @implementation VLCLibrary
...@@ -57,8 +57,11 @@ static void *DestroySharedLibraryAtExit() ...@@ -57,8 +57,11 @@ static void *DestroySharedLibraryAtExit()
{ {
if (!sharedLibrary) if (!sharedLibrary)
{ {
// Initialize a shared instance /* Initialize a shared instance */
[[self alloc] init]; sharedLibrary = [[self alloc] init];
/* Make sure, this will get released at some point */
atexit( (void*)DestroySharedLibraryAtExit );
} }
return [[sharedLibrary retain] autorelease]; return [[sharedLibrary retain] autorelease];
} }
...@@ -89,15 +92,11 @@ static void *DestroySharedLibraryAtExit() ...@@ -89,15 +92,11 @@ static void *DestroySharedLibraryAtExit()
instance = (void *)libvlc_new( 7, lib_vlc_params, &ex ); instance = (void *)libvlc_new( 7, lib_vlc_params, &ex );
quit_on_exception( &ex ); quit_on_exception( &ex );
if (!sharedLibrary)
sharedLibrary = self;
// Assignment unneeded, as the audio unit will do it for us // Assignment unneeded, as the audio unit will do it for us
/*audio = */ [[VLCAudio alloc] initWithLibrary:self]; /*audio = */ [[VLCAudio alloc] initWithLibrary:self];
// free allocated resources // free allocated resources
free( applicationPath ); free( applicationPath );
atexit(DestroySharedLibraryAtExit);
} }
return self; return self;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment