]> git.sesse.net Git - vlc/commitdiff
macosx/VLCKit: Load VLCLibrary when VLCKit is loaded. No longer need atexit( .....
authorFaustino Osuna <enrique.osuna@gmail.com>
Tue, 4 Mar 2008 22:41:30 +0000 (22:41 +0000)
committerFaustino Osuna <enrique.osuna@gmail.com>
Tue, 4 Mar 2008 22:41:30 +0000 (22:41 +0000)
projects/macosx/framework/Headers/Public/VLCLibrary.h
projects/macosx/framework/Sources/VLCLibrary.m

index f1ff8c5b6bf4519e225755100e8c962416a0a05c..a3d6c3590994fdc3ce5ca03ae3b20243584517b9 100644 (file)
 #import "VLCMediaList.h"
 #import "VLCMedia.h"
 
+
+extern void * CreateSharedLibraryOnStartup( void ) __attribute__((constructor));
+extern void * DestroySharedLibraryAtExit( void ) __attribute__((destructor));
+
 @class VLCAudio;
 
 /**
index b58e011241b97dedd118082d269f74800e00a582..2550a4896b67e2ac787007c95e05a3da725150a1 100644 (file)
@@ -49,7 +49,20 @@ void __catch_exception( void * e, const char * function, const char * file, int
     }
 }
 
-static void * DestroySharedLibraryAtExit( void )
+void * CreateSharedLibraryOnStartup( void ) 
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    
+    /* This library is not loaded for no reason, so let's create
+     * a VLCLibrary instance. */
+    [VLCLibrary sharedLibrary];
+    
+    [pool release];
+    
+    return NULL;
+}
+
+void * DestroySharedLibraryAtExit( void )
 {
     /* Release the global object that may have been alloc-ed
      * in -[VLCLibrary init] */
@@ -66,11 +79,8 @@ static void * DestroySharedLibraryAtExit( void )
     {
         /* Initialize a shared instance */
         sharedLibrary = [[self alloc] init];
-        
-        /* Make sure, this will get released at some point */
-        atexit( (void *)DestroySharedLibraryAtExit );
     }
-    return [[sharedLibrary retain] autorelease];
+    return sharedLibrary;
 }
 
 - (id)init