vlc | branch: master | Felix Paul Kühne <[email protected]> | Tue Jan 29 11:50:01 2019 +0100| [c2a24a2576d3482ab251488043688997dabeb439] | committer: Felix Paul Kühne
macosx/open: don't iterate on mounted volumes on the main thread Asking NSFileManager for the mounted devices can take very long (>6s) when the devices are slow to respond, so let's do that on the background thread and don't delay display of the open panel. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c2a24a2576d3482ab251488043688997dabeb439 --- modules/gui/macosx/VLCOpenWindowController.m | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/gui/macosx/VLCOpenWindowController.m b/modules/gui/macosx/VLCOpenWindowController.m index 257a288a2b..e462d8275a 100644 --- a/modules/gui/macosx/VLCOpenWindowController.m +++ b/modules/gui/macosx/VLCOpenWindowController.m @@ -311,6 +311,7 @@ static NSString *kCaptureTabViewId = @"capture"; [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil]; [self qtkToggleUIElements:nil]; + [self updateMediaSelector:nil]; [self scanOpticalMedia:nil]; [self setMRL: @""]; @@ -808,13 +809,14 @@ static NSString *kCaptureTabViewId = @"capture"; image, @"image", nil]; } -- (void)scanDevicesWithPaths:(NSArray *)paths +- (void)scanDevices { @autoreleasepool { - NSUInteger count = [paths count]; + NSArray *mountURLs = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:@[NSURLVolumeIsRemovableKey] options:NSVolumeEnumerationSkipHiddenVolumes]; + NSUInteger count = [mountURLs count]; NSMutableArray *o_result = [NSMutableArray array]; for (NSUInteger i = 0; i < count; i++) { - NSURL *currentURL = [paths objectAtIndex:i]; + NSURL *currentURL = [mountURLs objectAtIndex:i]; NSNumber *isRemovable = nil; if (![currentURL getResourceValue:&isRemovable forKey:NSURLVolumeIsRemovableKey error:nil] || !isRemovable) { @@ -851,9 +853,7 @@ static NSString *kCaptureTabViewId = @"capture"; - (void)scanOpticalMedia:(NSNotification *)o_notification { - NSArray *mountURLs = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:@[NSURLVolumeIsRemovableKey] options:NSVolumeEnumerationSkipHiddenVolumes]; - - [NSThread detachNewThreadSelector:@selector(scanDevicesWithPaths:) toTarget:self withObject:mountURLs]; + [NSThread detachNewThreadSelector:@selector(scanDevices) toTarget:self withObject:nil]; } - (void)updateMediaSelector:(NSNumber *)selection @@ -891,7 +891,6 @@ static NSString *kCaptureTabViewId = @"capture"; [self setMRL:@""]; [self showOpticalMediaView: _discNoDiscView withIcon: [NSImage imageNamed: @"NSApplicationIcon"]]; } - } - (IBAction)discSelectorChanged:(id)sender _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
