Commit 62166376 authored by David Fuhrmann's avatar David Fuhrmann

macosx: be more tolerant when checking for physical device (fixes #6253)

parent bfa8edd8
...@@ -886,10 +886,10 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -886,10 +886,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
if (noErr == err) if (noErr == err)
actualVolume = catalogInfo.volume; actualVolume = catalogInfo.volume;
else else
return NULL; goto out;
} }
else else
return NULL; goto out;
GetVolParmsInfoBuffer volumeParms; GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms)); err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
...@@ -897,66 +897,70 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -897,66 +897,70 @@ static VLCOpen *_o_sharedMainInstance = nil;
CFMutableDictionaryRef matchingDict; CFMutableDictionaryRef matchingDict;
io_service_t service; io_service_t service;
if (!volumeParms.vMDeviceID) if (!volumeParms.vMDeviceID) {
return NULL; goto out;
}
matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID); matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict); service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
NSString *returnValue;
NSString *returnValue = nil;
if (IO_OBJECT_NULL != service) { if (IO_OBJECT_NULL != service) {
if (IOObjectConformsTo(service, kIOCDMediaClass)) { if (IOObjectConformsTo(service, kIOCDMediaClass))
returnValue = kVLCMediaAudioCD; returnValue = kVLCMediaAudioCD;
}
else if (IOObjectConformsTo(service, kIODVDMediaClass)) else if (IOObjectConformsTo(service, kIODVDMediaClass))
returnValue = kVLCMediaDVD; returnValue = kVLCMediaDVD;
else if (IOObjectConformsTo(service, kIOBDMediaClass)) else if (IOObjectConformsTo(service, kIOBDMediaClass))
returnValue = kVLCMediaBD; returnValue = kVLCMediaBD;
else { IOObjectRelease(service);
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;
}
}
}
[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; returnValue = kVLCMediaVideoTSFolder;
break;
}
} }
} }
IOObjectRelease(service); [fm release];
if (!returnValue)
returnValue = kVLCMediaVideoTSFolder;
} }
return returnValue; return returnValue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment