[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    Audio CD detection
From:       Andreas Mohr <amohr () student ! ei ! uni-stuttgart ! de>
Date:       1999-12-19 18:13:18
[Download RAW message or body]

Hi all,

this adds automatic audio CD detection and provides the necessary label
"Audio CD" for DRIVE_GetLabel.

Andreas Mohr

["diff.audiocd" (text/plain)]

Index: files/drive.c
===================================================================
RCS file: /home/wine/wine/files/drive.c,v
retrieving revision 1.28
diff -u -w -r1.28 drive.c
--- files/drive.c	1999/12/08 03:56:27	1.28
+++ files/drive.c	1999/12/19 18:40:46
@@ -37,6 +37,7 @@
 #include "wine/winestring.h"  /* for lstrcpyAtoW */
 #include "winerror.h"
 #include "drive.h"
+#include "cdrom.h"
 #include "file.h"
 #include "heap.h"
 #include "msdos.h"
@@ -111,7 +112,8 @@
     {
         if (!strcasecmp( buffer, DRIVE_Types[i] )) return (DRIVETYPE)i;
     }
-    MESSAGE("%s: unknown type '%s', defaulting to 'hd'.\n", name, buffer );
+    MESSAGE("%s: unknown drive type '%s', defaulting to 'hd'.\n",
+	name, buffer );
     return TYPE_HD;
 }
 
@@ -400,7 +402,33 @@
  */
 const char * DRIVE_GetLabel( int drive )
 {
+    int read = 0;
+
     if (!DRIVE_IsValid( drive )) return NULL;
+    if (DRIVE_GetType(drive) == TYPE_CDROM)
+    {
+       WINE_CDAUDIO wcda;
+
+       if (!(CDAUDIO_Open(&wcda)))
+       {
+           int media = CDAUDIO_GetMediaType(&wcda);
+
+           if (media == CDS_AUDIO)
+            {
+               strcpy(DOSDrives[drive].label, "Audio CD");
+               read = 1;
+           }
+            else
+            if (media == CDS_NO_INFO)
+           {
+               strcpy(DOSDrives[drive].label, "           ");
+               read = 1;
+            }
+
+           CDAUDIO_Close(&wcda);
+       }
+    }
+
     return DOSDrives[drive].label;
 }
 
@@ -922,7 +950,7 @@
 
 /***********************************************************************
  *           GetDriveType16   (KERNEL.136)
- * This functions returns the drivetype of a drive in Win16. 
+ * This functions returns the type of a drive in Win16. 
  * Note that it returns DRIVE_REMOTE for CD-ROMs, since MSCDEX uses the
  * remote drive API. The returnvalue DRIVE_REMOTE for CD-ROMs has been
  * verified on Win3.11 and Windows 95. Some programs rely on it, so don't
@@ -972,7 +1000,7 @@
  *
  *  Currently returns DRIVE_DOESNOTEXIST and DRIVE_CANNOTDETERMINE
  *  when it really should return DRIVE_NO_ROOT_DIR and DRIVE_UNKNOWN.
- *  Why where the former defines used?
+ *  Why were the former defines used?
  *
  *  DRIVE_RAMDISK is unsupported.
  */
@@ -1173,7 +1201,11 @@
     int drive;
 
     for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
-        if (DRIVE_IsValid(drive)) ret |= (1 << drive);
+    {
+        if ( (DRIVE_IsValid(drive)) ||
+            (DOSDrives[drive].type == TYPE_CDROM)) /* audio CD is also valid */
+            ret |= (1 << drive);
+    }
     return ret;
 }
 
@@ -1189,7 +1221,7 @@
     int drive;
     char *cp;
 
-    /* FIXME, SetLastErrors missing */
+    /* FIXME, SetLastError()s missing */
 
     if (!root) drive = DRIVE_GetCurrentDrive();
     else
@@ -1212,7 +1244,7 @@
     if (serial) *serial = DRIVE_GetSerialNumber(drive);
 
     /* Set the filesystem information */
-    /* Note: we only emulate a FAT fs at the present */
+    /* Note: we only emulate a FAT fs at present */
 
     if (filename_len) {
     	if (DOSDrives[drive].flags & DRIVE_SHORT_NAMES)
Index: include/cdrom.h
===================================================================
RCS file: /home/wine/wine/include/cdrom.h,v
retrieving revision 1.5
diff -u -w -r1.5 cdrom.h
--- include/cdrom.h	1999/03/15 15:14:43	1.5
+++ include/cdrom.h	1999/12/19 18:40:50
@@ -51,6 +51,7 @@
 #define	WINE_CDA_PAUSE			0x05
 
 int	CDAUDIO_Open(WINE_CDAUDIO* wcda);
+int	CDAUDIO_GetMediaType(WINE_CDAUDIO* wcda);
 int	CDAUDIO_Close(WINE_CDAUDIO* wcda);
 int	CDAUDIO_Reset(WINE_CDAUDIO* wcda);
 int	CDAUDIO_Play(WINE_CDAUDIO* wcda, DWORD start, DWORD stop);
@@ -69,6 +70,10 @@
 #ifndef CDROM_DATA_TRACK
 #define CDROM_DATA_TRACK 0x04
 #endif
+
+/* values borrowed from Linux 2.2.x cdrom.h */
+#define CDS_NO_INFO			0
+#define CDS_AUDIO			100
 
 #endif
 
Index: misc/cdrom.c
===================================================================
RCS file: /home/wine/wine/misc/cdrom.c,v
retrieving revision 1.6
diff -u -w -r1.6 cdrom.c
--- misc/cdrom.c	1999/06/26 19:09:10	1.6
+++ misc/cdrom.c	1999/12/19 18:40:57
@@ -52,6 +52,18 @@
 }
 
 /**************************************************************************
+ * 				CDAUDIO_GetMediaType		[internal]
+ */
+int	CDAUDIO_GetMediaType(WINE_CDAUDIO* wcda)
+{
+#ifdef linux
+    return ioctl(wcda->unixdev, CDROM_DISC_STATUS);
+#else
+    return -1;
+#endif
+}
+
+/**************************************************************************
  * 				CDAUDIO_Close			[internal]
  */
 int	CDAUDIO_Close(WINE_CDAUDIO* wcda)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic