Commit b56a6d0f authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed drag & drop handling of optical media by re-writing it

(cherry picked from commit c789f858d4a31d65be4af4866573e81ae0bc543d)

Conflicts:

	modules/gui/macosx/open.m
parent 9c3dd03b
...@@ -35,6 +35,8 @@ Audio filters and output: ...@@ -35,6 +35,8 @@ Audio filters and output:
Mac OS X: Mac OS X:
* Fullscreen fixes and video output improvements * Fullscreen fixes and video output improvements
* Keep Aspect Ratio when resizing is back * Keep Aspect Ratio when resizing is back
* Fix crash when trying to open an Audio CD by drag & drop
* Improve reliability when opening DVDs or BRs by drag & drop
* Fix crash on exit * Fix crash on exit
* Fix crash when mounting a device with multiple logical volumes while * Fix crash when mounting a device with multiple logical volumes while
VLC is running VLC is running
......
...@@ -24,6 +24,15 @@ ...@@ -24,6 +24,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#define kVLCMediaAudioCD "AudioCD"
#define kVLCMediaDVD "DVD"
#define kVLCMediaVCD "VCD"
#define kVLCMediaSVCD "SVCD"
#define kVLCMediaBD "Bluray"
#define kVLCMediaVideoTSFolder "VIDEO_TS"
#define kVLCMediaBDMVFolder "BDMV"
#define kVLCMediaUnknown "Unknown"
/***************************************************************************** /*****************************************************************************
* Intf_Open interface * Intf_Open interface
*****************************************************************************/ *****************************************************************************/
...@@ -251,6 +260,8 @@ ...@@ -251,6 +260,8 @@
- (IBAction)openSpecialMediaFolder:(id)sender; - (IBAction)openSpecialMediaFolder:(id)sender;
- (IBAction)dvdreadOptionChanged:(id)sender; - (IBAction)dvdreadOptionChanged:(id)sender;
- (IBAction)vcdOptionChanged:(id)sender; - (IBAction)vcdOptionChanged:(id)sender;
- (char *)getVolumeTypeFromMountPath:(NSString *)mountPath;
- (NSString *)getBSDNodeFromMountPath:(NSString *)mountPath;
- (void)openNet; - (void)openNet;
- (IBAction)openNetModeChanged:(id)sender; - (IBAction)openNetModeChanged:(id)sender;
......
...@@ -58,16 +58,6 @@ NSArray *qtkvideoDevices; ...@@ -58,16 +58,6 @@ NSArray *qtkvideoDevices;
[o_capture_long_lbl displayIfNeeded]; \ [o_capture_long_lbl displayIfNeeded]; \
[self showCaptureView: o_capture_label_view] [self showCaptureView: o_capture_label_view]
#define kVLCMediaAudioCD "AudioCD"
#define kVLCMediaDVD "DVD"
#define kVLCMediaVCD "VCD"
#define kVLCMediaSVCD "SVCD"
#define kVLCMediaBD "Bluray"
#define kVLCMediaVideoTSFolder "VIDEO_TS"
#define kVLCMediaBDMVFolder "BDMV"
#define kVLCMediaUnknown "Unknown"
/***************************************************************************** /*****************************************************************************
* VLCOpen implementation * VLCOpen implementation
*****************************************************************************/ *****************************************************************************/
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#import "playlist.h" #import "playlist.h"
#import "controls.h" #import "controls.h"
#import "misc.h" #import "misc.h"
#import "open.h"
#include <vlc_keys.h> #include <vlc_keys.h>
#import <vlc_services_discovery.h> #import <vlc_services_discovery.h>
...@@ -1028,61 +1029,63 @@ ...@@ -1028,61 +1029,63 @@
playlist_t * p_playlist = pl_Get( p_intf ); playlist_t * p_playlist = pl_Get( p_intf );
input_item_t *p_input; input_item_t *p_input;
BOOL b_rem = FALSE, b_dir = FALSE; BOOL b_rem = FALSE, b_dir = FALSE, b_writable = FALSE;
NSString *o_uri, *o_name; NSString *o_uri, *o_name, *o_path;
NSURL * o_nsurl;
NSArray *o_options; NSArray *o_options;
NSURL *o_true_file; NSURL *o_true_file;
/* Get the item */ /* Get the item */
o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"]; o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
o_nsurl = [NSURL URLWithString: o_uri];
o_path = [o_nsurl path];
o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"]; o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"]; o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
/* Find the name for a disc entry (i know, can you believe the trouble?) */ if( [[NSFileManager defaultManager] fileExistsAtPath:o_path isDirectory:&b_dir] && b_dir &&
if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound ) [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:o_path isRemovable: &b_rem
isWritable:&b_writable isUnmountable:NULL description:NULL type:NULL] && b_rem && !b_writable && [o_nsurl isFileURL] )
{ {
int i_count;
struct statfs *mounts = NULL;
i_count = getmntinfo (&mounts, MNT_NOWAIT); id o_vlc_open = [[VLCMain sharedInstance] open];
/* getmntinfo returns a pointer to static data. Do not free. */
for( int i_index = 0 ; i_index < i_count; i_index++ ) char *diskType = [o_vlc_open getVolumeTypeFromMountPath: o_path];
msg_Dbg( p_intf, "detected optical media of type '%s' in the file input", diskType );
if (diskType == kVLCMediaDVD)
{ {
NSMutableString *o_temp, *o_temp2; o_uri = [NSString stringWithFormat: @"dvdnav://%@", [o_vlc_open getBSDNodeFromMountPath: o_path]];
o_temp = [NSMutableString stringWithString: o_uri]; }
o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname]; else if (diskType == kVLCMediaVideoTSFolder)
[o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ]; {
[o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ]; o_uri = [NSString stringWithFormat: @"dvdnav://%@", o_path];
[o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ]; }
else if (diskType == kVLCMediaAudioCD)
if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL ) {
{ o_uri = [NSString stringWithFormat: @"cdda://%@", [o_vlc_open getBSDNodeFromMountPath: o_path]];
o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]]; }
} else if (diskType == kVLCMediaVCD)
{
o_uri = [NSString stringWithFormat: @"vcd://%@#0:0", [o_vlc_open getBSDNodeFromMountPath: o_path]];
}
else if (diskType == kVLCMediaSVCD)
{
o_uri = [NSString stringWithFormat: @"vcd://%@@0:0", [o_vlc_open getBSDNodeFromMountPath: o_path]];
}
else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
{
o_uri = [NSString stringWithFormat: @"bluray://%@", o_path];
}
else
{
msg_Warn( VLCIntf, "unknown disk type, treating %s as regular input", [o_path UTF8String] );
} }
}
if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
[[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
{
/* All of this is to make sure CD's play when you D&D them on VLC */
/* Converts mountpoint to a /dev file */
struct statfs *buf;
char *psz_dev;
NSMutableString *o_temp;
buf = (struct statfs *) malloc (sizeof(struct statfs)); p_input = input_item_New( [o_uri UTF8String], [[[NSFileManager defaultManager] displayNameAtPath: o_path] UTF8String] );
statfs( [o_uri fileSystemRepresentation], buf );
psz_dev = strdup(buf->f_mntfromname);
o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
[o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
[o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
[o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
o_uri = o_temp;
} }
else
p_input = input_item_New( [o_uri fileSystemRepresentation], o_name ? [o_name UTF8String] : NULL );
p_input = input_item_New( [o_uri fileSystemRepresentation], o_name ? [o_name UTF8String] : NULL );
if( !p_input ) if( !p_input )
return NULL; return NULL;
...@@ -1097,11 +1100,9 @@ ...@@ -1097,11 +1100,9 @@
} }
/* Recent documents menu */ /* Recent documents menu */
o_true_file = [NSURL URLWithString: o_uri]; if( o_nsurl != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
if( o_true_file != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
{ {
[[NSDocumentController sharedDocumentController] [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_nsurl];
noteNewRecentDocumentURL: o_true_file];
} }
return p_input; return p_input;
} }
......
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