X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fopen.m;h=7cbe46357d5f0340ac6ecea6db5fad2fb42aac3c;hb=b2525ebf7c3658d72963def5d9ac5b7627ac3b4c;hp=7ee04b58d65c1b4bac0e416163c5e1a053f4c426;hpb=04b45e8ffd279a6df19ff96d6157a688bd6b7a08;p=vlc diff --git a/modules/gui/macosx/open.m b/modules/gui/macosx/open.m index 7ee04b58d6..7cbe46357d 100644 --- a/modules/gui/macosx/open.m +++ b/modules/gui/macosx/open.m @@ -71,6 +71,8 @@ struct display_info_t *****************************************************************************/ @implementation VLCOpen +@synthesize fileSubDelay, fileSubFps; + #pragma mark - #pragma mark Init @@ -152,31 +154,24 @@ static VLCOpen *_o_sharedMainInstance = nil; [o_disc_selector_pop removeAllItems]; [o_disc_selector_pop setHidden: NO]; - NSString *o_videots = _NS("Open VIDEO_TS folder"); - NSString *o_bdmv = _NS("Open BDMV folder"); + NSString *o_videots = _NS("Open VIDEO_TS / BDMV folder"); [o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")]; [o_disc_nodisc_videots_btn setTitle: o_videots]; - [o_disc_nodisc_bdmv_btn setTitle: o_bdmv]; [o_disc_audiocd_lbl setStringValue: _NS("Audio CD")]; [o_disc_audiocd_trackcount_lbl setStringValue: @""]; [o_disc_audiocd_videots_btn setTitle: o_videots]; - [o_disc_audiocd_bdmv_btn setTitle: o_bdmv]; [o_disc_dvd_lbl setStringValue: @""]; [o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")]; [o_disc_dvd_videots_btn setTitle: o_videots]; - [o_disc_dvd_bdmv_btn setTitle: o_bdmv]; [o_disc_dvdwomenus_lbl setStringValue: @""]; [o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")]; [o_disc_dvdwomenus_videots_btn setTitle: o_videots]; - [o_disc_dvdwomenus_bdmv_btn setTitle: o_bdmv]; [o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")]; [o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")]; [o_disc_vcd_title_lbl setStringValue: _NS("Title")]; [o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")]; [o_disc_vcd_videots_btn setTitle: o_videots]; - [o_disc_vcd_bdmv_btn setTitle: o_bdmv]; [o_disc_bd_videots_btn setTitle: o_videots]; - [o_disc_bd_bdmv_btn setTitle: o_bdmv]; [o_net_udp_port_lbl setStringValue: _NS("Port")]; [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")]; @@ -322,8 +317,9 @@ static VLCOpen *_o_sharedMainInstance = nil; [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil]; [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil]; - [self performSelector:@selector(qtkToggleUIElements:) withObject:nil afterDelay:.3]; - [self performSelector:@selector(scanOpticalMedia:) withObject:nil afterDelay:.5]; + + [self qtkToggleUIElements:nil]; + [self scanOpticalMedia:nil]; [self setMRL: @""]; } @@ -441,8 +437,8 @@ static VLCOpen *_o_sharedMainInstance = nil; [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", o_sub_path]]; if ([o_file_sub_override state] == NSOnState) { - [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)([o_file_sub_delay intValue] * 10)]]; - [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]]; + [o_options addObject: [NSString stringWithFormat: @"sub-delay=%f", ([self fileSubDelay] * 10)]]; + [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [self fileSubFps]]]; } [o_options addObject: [NSString stringWithFormat: @"subsdec-encoding=%@", [[o_file_sub_encoding_pop selectedItem] representedObject]]]; @@ -461,7 +457,7 @@ static VLCOpen *_o_sharedMainInstance = nil; if ([o_file_custom_timing_ckb state] == NSOnState) { NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"]; NSUInteger componentCount = [components count]; - NSInteger tempValue; + NSInteger tempValue = 0; if (componentCount == 1) tempValue = [[components objectAtIndex:0] intValue]; else if (componentCount == 2) @@ -521,9 +517,9 @@ static VLCOpen *_o_sharedMainInstance = nil; /* apply the options to our item(s) */ [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"]; if (b_autoplay) - [[[VLCMain sharedInstance] playlist] appendArray: @[o_dic] atPos: -1 enqueue:NO]; + [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:NO]; else - [[[VLCMain sharedInstance] playlist] appendArray: @[o_dic] atPos: -1 enqueue:YES]; + [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:YES]; } } @@ -829,7 +825,7 @@ static VLCOpen *_o_sharedMainInstance = nil; [[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] displayIfNeeded]; } -- (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath ++ (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath { OSStatus err; FSRef ref; @@ -857,14 +853,14 @@ static VLCOpen *_o_sharedMainInstance = nil; GetVolParmsInfoBuffer volumeParms; err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms)); if (noErr == err) { - NSString *bsdName = @((char *)volumeParms.vMDeviceID); + NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID]; return [NSString stringWithFormat:@"/dev/r%@", bsdName]; } return @""; } -- (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath ++ (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath { OSStatus err; FSRef ref; @@ -884,10 +880,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)); @@ -895,66 +891,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; } @@ -1003,17 +1003,24 @@ static VLCOpen *_o_sharedMainInstance = nil; - (NSDictionary *)scanPath:(NSString *)o_path { - NSString *o_type = [self getVolumeTypeFromMountPath:o_path]; + NSString *o_type = [VLCOpen getVolumeTypeFromMountPath:o_path]; NSImage *o_image = [[NSWorkspace sharedWorkspace] iconForFile: o_path]; NSString *o_device_path; + // BDMV path must not end with BDMV directory + if([o_type isEqualToString: kVLCMediaBDMVFolder]) { + if([[o_path lastPathComponent] isEqualToString: @"BDMV"]) { + o_path = [o_path stringByDeletingLastPathComponent]; + } + } + if ([o_type isEqualToString: kVLCMediaVideoTSFolder] || [o_type isEqualToString: kVLCMediaBD] || [o_type isEqualToString: kVLCMediaBDMVFolder] || [o_type isEqualToString: kVLCMediaUnknown]) o_device_path = o_path; else - o_device_path = [self getBSDNodeFromMountPath:o_path]; + o_device_path = [VLCOpen getBSDNodeFromMountPath:o_path]; return [NSDictionary dictionaryWithObjectsAndKeys: o_path, @"path", o_device_path, @"devicePath", @@ -1050,7 +1057,7 @@ static VLCOpen *_o_sharedMainInstance = nil; [o_specialMediaFolders addObject:o_dict]; } - [self performSelectorOnMainThread:@selector(updateMediaSelector:) withObject:@YES waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(updateMediaSelector:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:NO]; [o_pool release]; } @@ -1113,7 +1120,7 @@ static VLCOpen *_o_sharedMainInstance = nil; /* work-around for Mountain Lion, which treats folders called "BDMV" including an item named "INDEX.BDM" * as a _FILE_. Don't ask, move on. There is nothing to see here */ [o_open_panel setCanChooseFiles: YES]; - [o_open_panel setAllowedFileTypes:@[@"public.directory"]]; + [o_open_panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.directory"]]; if ([o_open_panel runModal] == NSOKButton) { NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path]; @@ -1487,7 +1494,7 @@ static VLCOpen *_o_sharedMainInstance = nil; if (channels) { NSString *channel; [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]]; - while (channel = [channels nextObject]) + while ((channel = [channels nextObject]) != nil) /* we have to add items this way, because we accept duplicates * additionally, we save a bit of time */ [[[o_eyetv_channels_pop menu] addItemWithTitle: channel action: nil keyEquivalent: @""] setTag:++x]; @@ -1569,16 +1576,6 @@ static VLCOpen *_o_sharedMainInstance = nil; [o_file_sub_fps_stp setEnabled: b_state]; } -- (IBAction)subDelayStepperChanged:(id)sender -{ - [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]]; -} - -- (IBAction)subFpsStepperChanged:(id)sender; -{ - [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]]; -} - #pragma mark - #pragma mark Miscellaneous