|
@@ -2,7 +2,7 @@
|
|
|
* VLCMediaDiscoverer.m: VLCKit.framework VLCMediaDiscoverer implementation
|
|
|
*****************************************************************************
|
|
|
* Copyright (C) 2007 Pierre d'Herbemont
|
|
|
- * Copyright (C) 2014-2015 Felix Paul Kühne
|
|
|
+ * Copyright (C) 2014-2017 Felix Paul Kühne
|
|
|
* Copyright (C) 2007, 2015 VLC authors and VideoLAN
|
|
|
* $Id$
|
|
|
*
|
|
@@ -44,6 +44,7 @@ NSString *const VLCMediaDiscovererCategory = @"VLCMediaDiscovererCategory";
|
|
|
libvlc_media_discoverer_t *_mdis;
|
|
|
|
|
|
VLCLibrary *_privateLibrary;
|
|
|
+ dispatch_queue_t _libVLCBackgroundQueue;
|
|
|
}
|
|
|
@end
|
|
|
|
|
@@ -92,6 +93,7 @@ NSString *const VLCMediaDiscovererCategory = @"VLCMediaDiscovererCategory";
|
|
|
if (self = [super init]) {
|
|
|
_localizedName = nil;
|
|
|
_discoveredMedia = nil;
|
|
|
+ _libVLCBackgroundQueue = dispatch_queue_create("libvlcQueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
|
|
|
|
|
|
if (libraryInstance != nil) {
|
|
|
_privateLibrary = libraryInstance;
|
|
@@ -113,14 +115,16 @@ NSString *const VLCMediaDiscovererCategory = @"VLCMediaDiscovererCategory";
|
|
|
|
|
|
- (void)dealloc
|
|
|
{
|
|
|
+ [[VLCEventManager sharedManager] cancelCallToObject:self];
|
|
|
+
|
|
|
if (_mdis) {
|
|
|
- if (libvlc_media_discoverer_is_running(_mdis))
|
|
|
- libvlc_media_discoverer_stop(_mdis);
|
|
|
- libvlc_media_discoverer_release(_mdis);
|
|
|
+ dispatch_sync(_libVLCBackgroundQueue, ^{
|
|
|
+ if (libvlc_media_discoverer_is_running(_mdis))
|
|
|
+ libvlc_media_discoverer_stop(_mdis);
|
|
|
+ libvlc_media_discoverer_release(_mdis);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- [[VLCEventManager sharedManager] cancelCallToObject:self];
|
|
|
-
|
|
|
libvlc_release(_privateLibrary.instance);
|
|
|
}
|
|
|
|
|
@@ -143,12 +147,13 @@ NSString *const VLCMediaDiscovererCategory = @"VLCMediaDiscovererCategory";
|
|
|
|
|
|
- (void)stopDiscoverer
|
|
|
{
|
|
|
- if ([NSThread isMainThread]) {
|
|
|
- [self performSelectorInBackground:@selector(stopDiscoverer) withObject:nil];
|
|
|
+ if (![self isRunning]) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- libvlc_media_discoverer_stop(_mdis);
|
|
|
+ dispatch_async(_libVLCBackgroundQueue, ^{
|
|
|
+ libvlc_media_discoverer_stop(_mdis);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- (VLCMediaList *)discoveredMedia
|