changeset 9535:aa0dd1f998d9

Dynamic decision of DVD device Darwin patch by (danchr at daimi dot au dot dk)
author michael
date Wed, 05 Mar 2003 10:56:47 +0000
parents 87e03d96a4cd
children 4521b6b6348e
files configure libmpdemux/open.c
diffstat 2 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Wed Mar 05 10:38:56 2003 +0000
+++ b/configure	Wed Mar 05 10:56:47 2003 +0000
@@ -5342,8 +5342,8 @@
 #elif defined(WIN32)
 #define DEFAULT_CDROM_DEVICE    "D:"
 #define DEFAULT_DVD_DEVICE	"D:"
-#elif defined(MACOSX)
-#define DEFAULT_CDROM_DEVICE    "/dev/rdisk1"
+#elif defined(SYS_DARWIN)
+#define DEFAULT_CDROM_DEVICE    "/dev/rdiskN"
 #define DEFAULT_DVD_DEVICE	DEFAULT_CDROM_DEVICE
 #else
 #define DEFAULT_CDROM_DEVICE    "/dev/cdrom"
--- a/libmpdemux/open.c	Wed Mar 05 10:38:56 2003 +0000
+++ b/libmpdemux/open.c	Wed Mar 05 10:56:47 2003 +0000
@@ -221,10 +221,33 @@
      * Open the disc.
      */
     if(!dvd_device) dvd_device=strdup(DEFAULT_DVD_DEVICE);
-    dvd = DVDOpen(dvd_device);
-    if( !dvd ) {
-        mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device);
-        return NULL;
+#ifdef SYS_DARWIN
+    /* Dynamic DVD drive selection on Darwin */
+    if (!strcmp(dvd_device, "/dev/rdiskN")) {
+	int i;
+	char *temp_device = malloc((strlen(dvd_device)+1)*sizeof(char));
+	
+	for (i = 1; i < 10; i++) {
+	    sprintf(temp_device, "/dev/rdisk%d", i);
+	    dvd = DVDOpen(temp_device);
+	    if (!dvd) {
+	        mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,temp_device);
+	    } else {
+	        free(temp_device);
+	        break;
+	    }
+	}
+	
+	if (!dvd)
+	    return NULL;
+    } else
+#endif /* SYS_DARWIN */
+    {
+        dvd = DVDOpen(dvd_device);
+	if( !dvd ) {
+	    mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CantOpenDVD,dvd_device);
+	    return NULL;
+	}
     }
 
     mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_DVDwait);