Commit 0e514bd7 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCLibrary.m: Better memory management for the global...

MacOSX/Framework/VLCLibrary.m: Better memory management for the global VLCLibrary object. Give an autoreleased object in +[VLCLibrary sharedLibrary]. Release the global VLCLibrary atexit.
parent 87bc7007
......@@ -44,8 +44,8 @@ void __quit_on_exception( void * e, const char * function, const char * file, in
static void *DestroySharedLibraryAtExit()
{
// Destroy the shared library
if (sharedLibrary)
/* Release the global object that may have been alloc-ed
* in -[VLCLibrary init] */
[sharedLibrary release];
sharedLibrary = nil;
......@@ -59,11 +59,8 @@ static void *DestroySharedLibraryAtExit()
{
// Initialize a shared instance
[[self alloc] init];
// Register a function to gracefully destroy the shared library on exit.
atexit( (void*)DestroySharedLibraryAtExit );
}
return sharedLibrary;
return [[sharedLibrary retain] autorelease];
}
+ (void *)sharedInstance
......@@ -93,24 +90,20 @@ static void *DestroySharedLibraryAtExit()
quit_on_exception( &ex );
if (!sharedLibrary)
sharedLibrary = [[self retain] autorelease];
sharedLibrary = self;
// Assignment unneeded, as the audio unit will do it for us
/*audio = */ [[VLCAudio alloc] initWithLibrary:self];
// free allocated resources
free( applicationPath );
atexit(DestroySharedLibraryAtExit);
}
return self;
}
- (void)dealloc
{
// TODO: libvlc core locks up or has segfaults while shutting down, the
// following code allows for the framework to be removed without crashing
// the host application.
@try
{
if (instance)
{
libvlc_exception_t ex;
......@@ -118,13 +111,9 @@ static void *DestroySharedLibraryAtExit()
libvlc_destroy( instance, &ex );
}
}
@finally
{
instance = nil;
[audio release];
[super dealloc];
}
}
- (void *)instance
......
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