Skip to content
Snippets Groups Projects
Commit 9032a525 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

VLCLibrary: take stricter care of our shared library instance

parent 66877e95
No related branches found
Tags 2.1-rc2
No related merge requests found
......@@ -39,9 +39,6 @@
* instiantiation of VLCLibrary, as previously noted, this is done automatically by the dynamic link loader.
*/
@interface VLCLibrary : NSObject
{
void * instance;
}
/* Factories */
/**
......
......@@ -37,6 +37,14 @@
#include <vlc/libvlc_structures.h>
static VLCLibrary * sharedLibrary = nil;
static void * sharedInstance = nil;
@interface VLCLibrary()
{
void *instance;
}
@end
@implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary
......@@ -44,6 +52,7 @@ static VLCLibrary * sharedLibrary = nil;
if (!sharedLibrary) {
/* Initialize a shared instance */
sharedLibrary = [[self alloc] init];
sharedInstance = sharedLibrary.instance;
}
return sharedLibrary;
}
......@@ -166,8 +175,11 @@ static VLCLibrary * sharedLibrary = nil;
if (instance)
libvlc_release(instance);
if (self == sharedLibrary)
if (self == sharedLibrary) {
sharedLibrary = nil;
libvlc_release(sharedInstance);
sharedInstance = nil;
}
[super dealloc];
}
......@@ -177,9 +189,9 @@ static VLCLibrary * sharedLibrary = nil;
@implementation VLCLibrary (VLCLibVLCBridging)
+ (void *)sharedInstance
{
NSAssert([self sharedLibrary].instance, @"shared library doesn't have an instance");
NSAssert(sharedInstance, @"shared library doesn't have an instance");
return [self sharedLibrary].instance;
return sharedInstance;
}
- (void *)instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment