]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
Consistent strings to avoid duplications
[vlc] / modules / gui / macosx / open.m
index e64d5174b0e4454fd0a51360c977a590acba84ff..d37d497e085555aa44c9438434a8deefdbdf7dec 100644 (file)
@@ -47,6 +47,7 @@
 #import "open.h"
 #import "output.h"
 #import "eyetv.h"
+#import "misc.h"
 
 #import <vlc_url.h>
 
@@ -70,6 +71,8 @@ struct display_info_t
  *****************************************************************************/
 @implementation VLCOpen
 
+@synthesize fileSubDelay, fileSubFps;
+
 #pragma mark -
 #pragma mark Init
 
@@ -151,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")];
@@ -204,12 +200,12 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
     [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
     [o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
-    [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
-    [o_screen_screen_lbl setStringValue: _NS("Screen:")];
-    [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
-    [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
-    [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
-    [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
+    [o_screen_fps_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Frames per Second")]];
+    [o_screen_screen_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Screen")]];
+    [o_screen_left_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen left")]];
+    [o_screen_top_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen top")]];
+    [o_screen_width_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen width")]];
+    [o_screen_height_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen height")]];
     [o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
     [o_screen_qtk_audio_ckb setTitle: _NS("Capture Audio")];
     [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
@@ -220,8 +216,12 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
     [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
     [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
-    [o_capture_width_lbl setStringValue: _NS("Image width:")];
-    [o_capture_height_lbl setStringValue: _NS("Image height:")];
+    [o_capture_width_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image width")]];
+    [o_capture_height_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image height")]];
+
+    // setup start / stop time fields
+    [o_file_starttime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
+    [o_file_stoptime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
 
     [self qtkvideoDevices];
     [o_qtk_video_device_pop removeAllItems];
@@ -236,9 +236,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
         for (int ivideo = 0; ivideo < deviceCount; ivideo++) {
             QTCaptureDevice *qtk_device;
             qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
-            [o_qtk_video_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
+            // allow same name for multiple times
+            [[o_qtk_video_device_pop menu] addItemWithTitle:[qtk_device localizedDisplayName] action:nil keyEquivalent:@""];
 
-            if ([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid])
+            if ([[[qtk_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid])
                 [o_qtk_video_device_pop selectItemAtIndex:ivideo];
         }
     } else {
@@ -258,11 +259,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
         NSUInteger deviceCount = [qtkaudioDevices count];
         for (int iaudio = 0; iaudio < deviceCount; iaudio++) {
-            QTCaptureDevice *qtkaudio_device;
-            qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
-            [o_qtk_audio_device_pop addItemWithTitle: [qtkaudio_device localizedDisplayName]];
-            [o_screen_qtk_audio_pop addItemWithTitle: [qtkaudio_device localizedDisplayName]];
-            if ([[[qtkaudio_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]) {
+            QTCaptureDevice *qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
+
+            // allow same name for multiple times
+            [[o_qtk_audio_device_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
+            [[o_screen_qtk_audio_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
+
+            if ([[[qtkaudio_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]) {
                 [o_qtk_audio_device_pop selectItemAtIndex:iaudio];
                 [o_screen_qtk_audio_pop selectItemAtIndex:iaudio];
             }
@@ -317,20 +320,24 @@ 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: @""];
 }
 
 - (void)setMRL:(NSString *)newMRL
 {
+    if (!newMRL)
+        newMRL = @"";
+
     if (o_mrl)
         [o_mrl release];
 
     o_mrl = newMRL;
     [o_mrl retain];
-    [o_mrl_fld setStringValue: o_mrl];
+    [o_mrl_fld performSelectorOnMainThread:@selector(setStringValue:) withObject:o_mrl waitUntilDone:NO];
     if ([o_mrl length] > 0)
         [o_btn_ok setEnabled: YES];
     else
@@ -348,7 +355,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     module_config_t * p_item;
     intf_thread_t * p_intf = VLCIntf;
 
-    [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
+    [o_file_sub_ckbox setTitle: _NS("Add Subtitle File:")];
     [o_file_sub_path_lbl setStringValue: _NS("Choose a file")];
     [o_file_sub_path_lbl setHidden: NO];
     [o_file_sub_path_fld setStringValue: @""];
@@ -361,11 +368,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_file_sub_delay_stp setEnabled: NO];
     [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
     [o_file_sub_fps_stp setEnabled: NO];
-    [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
+    [o_file_sub_encoding_lbl setStringValue: _NS("Subtitle encoding")];
     [o_file_sub_encoding_pop removeAllItems];
     [o_file_sub_size_lbl setStringValue: _NS("Font size")];
     [o_file_sub_size_pop removeAllItems];
-    [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
+    [o_file_sub_align_lbl setStringValue: _NS("Subtitle alignment")];
     [o_file_sub_align_pop removeAllItems];
     [o_file_sub_ok_btn setStringValue: _NS("OK")];
     [[o_file_sub_ok_btn cell] accessibilitySetOverrideValue:_NS("Click to dismiss the subtitle setup dialog.") forAttribute:NSAccessibilityDescriptionAttribute];
@@ -415,8 +422,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     int i_result;
 
-    b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
-
     [o_tabview selectTabViewItemAtIndex: i_type];
     [o_file_sub_ckbox setState: NSOffState];
 
@@ -433,8 +438,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]]];
@@ -450,32 +455,34 @@ static VLCOpen *_o_sharedMainInstance = nil;
                     p_item->list.i[[o_file_sub_size_pop indexOfSelectedItem]]]];
             }
         }
-        NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
-        NSUInteger componentCount = [components count];
-        NSInteger tempValue;
-        if (componentCount == 1)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue]);
-        else if (componentCount == 2)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
-        else if (componentCount == 3)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
-        if (tempValue > 0)
-            [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
-        components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
-        componentCount = [components count];
-        if (componentCount == 1)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue]);
-        else if (componentCount == 2)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
-        else if (componentCount == 3)
-            tempValue = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
-        if (tempValue > 0)
-            [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
+        if ([o_file_custom_timing_ckb state] == NSOnState) {
+            NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
+            NSUInteger componentCount = [components count];
+            NSInteger tempValue = 0;
+            if (componentCount == 1)
+                tempValue = [[components objectAtIndex:0] intValue];
+            else if (componentCount == 2)
+                tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
+            else if (componentCount == 3)
+                tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
+            if (tempValue > 0)
+                [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
+            components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
+            componentCount = [components count];
+            if (componentCount == 1)
+                tempValue = [[components objectAtIndex:0] intValue];
+            else if (componentCount == 2)
+                tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
+            else if (componentCount == 3)
+                tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
+            if (tempValue > 0)
+                [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
+        }
         if ([o_output_ckbox state] == NSOnState) {
             NSArray * soutMRL = [o_sout_options soutMRL];
             NSUInteger count = [soutMRL count];
             for (NSUInteger i = 0 ; i < count ; i++)
-                [o_options addObject: [NSString stringWithString: [soutMRL objectAtIndex: i]]];
+                [o_options addObject: [NSString stringWithString: [soutMRL objectAtIndex:i]]];
         }
         if ([o_file_slave_ckbox state] && o_file_slave_path)
            [o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
@@ -510,10 +517,8 @@ 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: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
-        else
-            [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
+
+        [[[VLCMain sharedInstance] playlist] addPlaylistItems:[NSArray arrayWithObject:o_dic]];
     }
 }
 
@@ -537,7 +542,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     NSInteger i_selectedDevice = [o_qtk_video_device_pop indexOfSelectedItem];
     if ([qtkvideoDevices count] >= 1) {
-        NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
+        NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex:0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
 
         [o_capture_width_fld setIntValue: [sizes sizeValue].width];
         [o_capture_height_fld setIntValue: [sizes sizeValue].height];
@@ -651,7 +656,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
 - (void)openFile
 {
     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
-    b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
 
     [o_open_panel setAllowsMultipleSelection: YES];
     [o_open_panel setCanChooseDirectories: YES];
@@ -664,7 +668,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
         NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
         for (NSUInteger i = 0; i < count; i++)
-            [o_values addObject: [[o_urls objectAtIndex: i] path]];
+            [o_values addObject: [[o_urls objectAtIndex:i] path]];
         [o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
 
         for (NSUInteger i = 0; i < count; i++) {
@@ -679,10 +683,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
             [o_array addObject: o_dic];
         }
-        if (b_autoplay)
-            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
-        else
-            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
+
+        [[[VLCMain sharedInstance] playlist] addPlaylistItems:o_array];
     }
 }
 
@@ -736,7 +738,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         if (returnCode == NSFileHandlingPanelOKButton) {
             if (o_file_path)
                 [o_file_path release];
-            o_file_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+            o_file_path = [[[o_open_panel URLs] objectAtIndex:0] path];
             [o_file_path retain];
             [self openFilePathChanged: nil];
         }
@@ -760,7 +762,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         if ([o_open_panel runModal] == NSOKButton) {
             if (o_file_slave_path)
                 [o_file_slave_path release];
-            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex:0] path];
             [o_file_slave_path retain];
         }
     }
@@ -819,7 +821,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;
@@ -854,7 +856,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     return @"";
 }
 
-- (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
++ (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
 {
     OSStatus err;
     FSRef ref;
@@ -874,10 +876,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));
@@ -885,66 +887,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;
 }
 
@@ -993,17 +999,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",
@@ -1062,7 +1075,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     NSUInteger count = [o_allMediaDevices count];
     if (count > 0) {
         for (NSUInteger i = 0; i < count ; i++) {
-            NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: i];
+            NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:i];
             [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_dict objectForKey:@"path"]]];
         }
 
@@ -1086,7 +1099,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)discSelectorChanged:(id)sender
 {
-    NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];    
+    NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];    
     [self showOpticalAtPath:o_dict];
 }
 
@@ -1103,10 +1116,10 @@ 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:[NSArray arrayWithObjects:@"public.directory", nil]];
+    [o_open_panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.directory"]];
 
     if ([o_open_panel runModal] == NSOKButton) {
-        NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+        NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
         if ([o_path length] > 0) {
             [NSThread detachNewThreadSelector:@selector(scanSpecialPath:) toTarget:self withObject:o_path];
         }
@@ -1115,7 +1128,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)dvdreadOptionChanged:(id)sender
 {
-    NSDictionary *o_dict = [o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];
+    NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
     NSString *o_device_path = [o_dict objectForKey:@"devicePath"];
 
     if (sender == o_disc_dvdwomenus_enablemenus_btn) {
@@ -1152,7 +1165,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     if (sender == o_disc_vcd_chapter_stp)
         [o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
 
-    NSString *o_device_path = [[o_allMediaDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]] objectForKey:@"devicePath"];
+    NSString *o_device_path = [[o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]] objectForKey:@"devicePath"];
     [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", o_device_path, [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
 }
 
@@ -1477,7 +1490,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];
@@ -1534,7 +1547,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_open_panel setPrompt: _NS("Open")];
 
     if ([o_open_panel runModal] == NSOKButton) {
-        o_sub_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+        o_sub_path = [[[o_open_panel URLs] objectAtIndex:0] path];
         [o_sub_path retain];
         [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
         [o_file_sub_path_fld setStringValue: [o_file_subtitles_filename_lbl stringValue]];
@@ -1559,16 +1572,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