[vlc-commits] macosx: be more tolerant when checking for physical device (fixes #6253)
David Fuhrmann
git at videolan.org
Sun Jan 26 15:02:25 CET 2014
vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sun Jan 26 15:00:41 2014 +0100| [62166376a88ca4c17e2318f05e2c8332977b290d] | committer: David Fuhrmann
macosx: be more tolerant when checking for physical device (fixes #6253)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=62166376a88ca4c17e2318f05e2c8332977b290d
---
modules/gui/macosx/open.m | 94 +++++++++++++++++++++++----------------------
1 file changed, 49 insertions(+), 45 deletions(-)
diff --git a/modules/gui/macosx/open.m b/modules/gui/macosx/open.m
index 565bd36..15b1cf6 100644
--- a/modules/gui/macosx/open.m
+++ b/modules/gui/macosx/open.m
@@ -886,10 +886,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
if (noErr == err)
actualVolume = catalogInfo.volume;
else
- return NULL;
+ goto out;
}
else
- return NULL;
+ goto out;
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
@@ -897,66 +897,70 @@ static VLCOpen *_o_sharedMainInstance = nil;
CFMutableDictionaryRef matchingDict;
io_service_t service;
- if (!volumeParms.vMDeviceID)
- return NULL;
+ if (!volumeParms.vMDeviceID) {
+ goto out;
+ }
matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
- NSString *returnValue;
+
+ NSString *returnValue = nil;
if (IO_OBJECT_NULL != service) {
- if (IOObjectConformsTo(service, kIOCDMediaClass)) {
+ if (IOObjectConformsTo(service, kIOCDMediaClass))
returnValue = kVLCMediaAudioCD;
- }
else if (IOObjectConformsTo(service, kIODVDMediaClass))
returnValue = kVLCMediaDVD;
else if (IOObjectConformsTo(service, kIOBDMediaClass))
returnValue = kVLCMediaBD;
- else {
- if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
- returnValue = kVLCMediaVideoTSFolder;
- else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
- returnValue = kVLCMediaBDMVFolder;
- else {
- // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
- NSFileManager * fm = [[NSFileManager alloc] init];
-
- NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
- for (int i = 0; i < [dirContents count]; i++) {
- NSString *currentFile = [dirContents objectAtIndex:i];
- NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
-
- BOOL isDir;
- if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
- {
- if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame) {
- returnValue = kVLCMediaSVCD;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame) {
- returnValue = kVLCMediaVCD;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame) {
- returnValue = kVLCMediaBDMVFolder;
- break;
- }
- if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame) {
- returnValue = kVLCMediaVideoTSFolder;
- break;
- }
- }
- }
+ IOObjectRelease(service);
- [fm release];
+ if (returnValue)
+ return returnValue;
+ }
- if (!returnValue)
+out:
+ if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+ returnValue = kVLCMediaVideoTSFolder;
+ else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+ returnValue = kVLCMediaBDMVFolder;
+ else {
+ // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
+ NSFileManager * fm = [[NSFileManager alloc] init];
+
+ NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
+ for (int i = 0; i < [dirContents count]; i++) {
+ NSString *currentFile = [dirContents objectAtIndex:i];
+ NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
+
+ BOOL isDir;
+ if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
+ {
+ if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame) {
+ returnValue = kVLCMediaSVCD;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame) {
+ returnValue = kVLCMediaVCD;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame) {
+ returnValue = kVLCMediaBDMVFolder;
+ break;
+ }
+ if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame) {
returnValue = kVLCMediaVideoTSFolder;
+ break;
+ }
}
}
- IOObjectRelease(service);
+ [fm release];
+
+ if (!returnValue)
+ returnValue = kVLCMediaVideoTSFolder;
}
+
return returnValue;
}
More information about the vlc-commits
mailing list