瀏覽代碼

VLCLibrary: retain the library instance since it's valuable

Felix Paul Kühne 12 年之前
父節點
當前提交
37bead5d6a
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      Sources/VLCLibrary.m

+ 5 - 0
Sources/VLCLibrary.m

@@ -63,6 +63,7 @@ static VLCLibrary * sharedLibrary = nil;
         }
         unsigned argc = sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]);
         instance = libvlc_new(argc, lib_vlc_params);
+        libvlc_retain(instance);
         NSAssert(instance, @"libvlc failed to initialize");
     }
     return self;
@@ -176,11 +177,15 @@ static VLCLibrary * sharedLibrary = nil;
 @implementation VLCLibrary (VLCLibVLCBridging)
 + (void *)sharedInstance
 {
+    NSAssert([self sharedLibrary].instance, @"shared library doesn't have an instance");
+
     return [self sharedLibrary].instance;
 }
 
 - (void *)instance
 {
+    NSAssert(instance, @"library doesn't have an instance");
+
     return instance;
 }
 @end