[MCICDA] Sync with Wine Staging 1.7.55. CORE-10536
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 21 Nov 2015 09:26:27 +0000 (09:26 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 21 Nov 2015 09:26:27 +0000 (09:26 +0000)
svn path=/trunk/; revision=69975

reactos/dll/win32/mcicda/mcicda.c
reactos/media/doc/README.WINE

index 00d7bb4..545bf7a 100644 (file)
@@ -81,6 +81,31 @@ typedef struct {
 typedef HRESULT(WINAPI*LPDIRECTSOUNDCREATE)(LPCGUID,LPDIRECTSOUND*,LPUNKNOWN);
 static LPDIRECTSOUNDCREATE pDirectSoundCreate;
 
+static BOOL device_io(HANDLE dev, DWORD code, void *inbuffer, DWORD insize, void *outbuffer, DWORD outsize, DWORD *retsize, OVERLAPPED *overlapped)
+{
+    const char *str;
+    BOOL ret = DeviceIoControl(dev, code, inbuffer, insize, outbuffer, outsize, retsize, overlapped);
+
+#define XX(x) case (x): str = #x; break
+    switch (code)
+    {
+        XX(IOCTL_CDROM_RAW_READ);
+        XX(IOCTL_CDROM_READ_TOC);
+        XX(IOCTL_CDROM_READ_Q_CHANNEL);
+        XX(IOCTL_CDROM_SEEK_AUDIO_MSF);
+        XX(IOCTL_CDROM_PLAY_AUDIO_MSF);
+        XX(IOCTL_CDROM_STOP_AUDIO);
+        XX(IOCTL_CDROM_PAUSE_AUDIO);
+        XX(IOCTL_CDROM_RESUME_AUDIO);
+        XX(IOCTL_STORAGE_EJECT_MEDIA);
+        XX(IOCTL_STORAGE_LOAD_MEDIA);
+        default: str = wine_dbg_sprintf("UNKNOWN (0x%x)", code);
+    };
+#undef XX
+    TRACE("Device %p, Code %s -> Return %d, Bytes %u\n", dev, str, ret, *retsize);
+    return ret;
+}
+
 static DWORD CALLBACK MCICDA_playLoop(void *ptr)
 {
     WINE_MCICDAUDIO *wmcda = (WINE_MCICDAUDIO*)ptr;
@@ -123,7 +148,7 @@ static DWORD CALLBACK MCICDA_playLoop(void *ptr)
 
         if (SUCCEEDED(hr)) {
             if (rdInfo.SectorCount > 0) {
-                if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_RAW_READ, &rdInfo, sizeof(rdInfo), cdData, lockLen, &br, NULL))
+                if (!device_io(wmcda->handle, IOCTL_CDROM_RAW_READ, &rdInfo, sizeof(rdInfo), cdData, lockLen, &br, NULL))
                     WARN("CD read failed at sector %d: 0x%x\n", wmcda->start, GetLastError());
             }
             if (rdInfo.SectorCount*RAW_SECTOR_SIZE < lockLen) {
@@ -256,7 +281,7 @@ static      DWORD    MCICDA_GetStatus(WINE_MCICDAUDIO* wmcda)
                 mode = MCI_MODE_PLAY;
         }
     }
-    else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
+    else if (!device_io(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
                               &data, sizeof(data), &br, NULL)) {
         if (GetLastError() == ERROR_NOT_READY) mode = MCI_MODE_OPEN;
     } else {
@@ -319,7 +344,7 @@ static DWORD MCICDA_CalcFrame(WINE_MCICDAUDIO* wmcda, DWORD dwTime)
     case MCI_FORMAT_TMSF:
     default: /* unknown format ! force TMSF ! ... */
        wTrack = MCI_TMSF_TRACK(dwTime);
-        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+        if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                              &toc, sizeof(toc), &br, NULL))
             return 0;
         if (wTrack < toc.FirstTrack || wTrack > toc.LastTrack)
@@ -370,7 +395,7 @@ static DWORD MCICDA_CalcTime(WINE_MCICDAUDIO* wmcda, DWORD tf, DWORD dwFrame, LP
        break;
     case MCI_FORMAT_TMSF:
     default:   /* unknown format ! force TMSF ! ... */
-        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+        if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                              &toc, sizeof(toc), &br, NULL))
             return 0;
        if (dwFrame < FRAME_OF_TOC(toc, toc.FirstTrack) ||
@@ -642,7 +667,7 @@ static DWORD MCICDA_Info(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW lpParms)
         DWORD       br;
        static const WCHAR wszLu[] = {'%','l','u',0};
 
-        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+        if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                              &toc, sizeof(toc), &br, NULL)) {
            return MCICDA_GetError(wmcda);
        }
@@ -657,10 +682,9 @@ static DWORD MCICDA_Info(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW lpParms)
     if (!ret) {
        TRACE("=> %s\n", debugstr_w(str));
        if (lpParms->dwRetSize) {
-           WCHAR zero = 0;
            /* FIXME? Since NT, mciwave, mciseq and mcicda set dwRetSize
             *        to the number of characters written, excluding \0. */
-           lstrcpynW(lpParms->lpstrReturn, str ? str : &zero, lpParms->dwRetSize);
+           lstrcpynW(lpParms->lpstrReturn, str, lpParms->dwRetSize);
        } else ret = MCIERR_PARAM_OVERFLOW;
     }
     if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY))
@@ -690,7 +714,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
        switch (lpParms->dwItem) {
        case MCI_STATUS_CURRENT_TRACK:
             fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
-            if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
+            if (!device_io(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
                                  &data, sizeof(data), &br, NULL))
             {
                return MCICDA_GetError(wmcda);
@@ -700,7 +724,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
             TRACE("CURRENT_TRACK=%lu\n", lpParms->dwReturn);
            break;
        case MCI_STATUS_LENGTH:
-            if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+            if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                                  &toc, sizeof(toc), &br, NULL)) {
                 WARN("error reading TOC !\n");
                 return MCICDA_GetError(wmcda);
@@ -742,7 +766,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
            ret = MCI_RESOURCE_RETURNED;
            break;
        case MCI_STATUS_NUMBER_OF_TRACKS:
-            if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+            if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                                  &toc, sizeof(toc), &br, NULL)) {
                 WARN("error reading TOC !\n");
                 return MCICDA_GetError(wmcda);
@@ -755,7 +779,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
        case MCI_STATUS_POSITION:
             switch (dwFlags & (MCI_STATUS_START | MCI_TRACK)) {
             case MCI_STATUS_START:
-                if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+                if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                                      &toc, sizeof(toc), &br, NULL)) {
                     WARN("error reading TOC !\n");
                     return MCICDA_GetError(wmcda);
@@ -764,7 +788,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
                TRACE("get MCI_STATUS_START !\n");
                 break;
             case MCI_TRACK:
-                if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+                if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                                      &toc, sizeof(toc), &br, NULL)) {
                     WARN("error reading TOC !\n");
                     return MCICDA_GetError(wmcda);
@@ -776,7 +800,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
                 break;
             case 0:
                 fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
-                if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
+                if (!device_io(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
                                      &data, sizeof(data), &br, NULL)) {
                     return MCICDA_GetError(wmcda);
                 }
@@ -813,7 +837,7 @@ static DWORD MCICDA_Status(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParm
            if (!(dwFlags & MCI_TRACK))
                ret = MCIERR_MISSING_PARAMETER;
            else {
-                if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+                if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                                      &toc, sizeof(toc), &br, NULL)) {
                     WARN("error reading TOC !\n");
                     return MCICDA_GetError(wmcda);
@@ -845,7 +869,7 @@ static DWORD MCICDA_SkipDataTracks(WINE_MCICDAUDIO* wmcda,DWORD *frame)
   int i;
   DWORD br;
   CDROM_TOC toc;
-  if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+  if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                       &toc, sizeof(toc), &br, NULL)) {
     WARN("error reading TOC !\n");
     return MCICDA_GetError(wmcda);
@@ -892,7 +916,7 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
     if (wmcda == NULL)
        return MCIERR_INVALID_DEVICE_ID;
 
-    if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+    if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                          &toc, sizeof(toc), &br, NULL)) {
         WARN("error reading TOC !\n");
         return MCICDA_GetError(wmcda);
@@ -905,7 +929,7 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
        TRACE("MCI_FROM=%08X -> %u\n", lpParms->dwFrom, start);
     } else {
         fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
-        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
+        if (!device_io(wmcda->handle, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
                              &data, sizeof(data), &br, NULL)) {
             return MCICDA_GetError(wmcda);
         }
@@ -997,7 +1021,7 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
                                      wmcda->end-wmcda->start);
             rdInfo.TrackMode = CDDA;
 
-            readok = DeviceIoControl(wmcda->handle, IOCTL_CDROM_RAW_READ,
+            readok = device_io(wmcda->handle, IOCTL_CDROM_RAW_READ,
                                      &rdInfo, sizeof(rdInfo), cdData, lockLen,
                                      &br, NULL);
             IDirectSoundBuffer_Unlock(wmcda->dsBuf, cdData, lockLen, NULL, 0);
@@ -1047,7 +1071,7 @@ static DWORD MCICDA_Play(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
     play.EndingM   = end / CDFRAMES_PERMIN;
     play.EndingS   = (end / CDFRAMES_PERSEC) % 60;
     play.EndingF   = end % CDFRAMES_PERSEC;
-    if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_PLAY_AUDIO_MSF, &play, sizeof(play),
+    if (!device_io(wmcda->handle, IOCTL_CDROM_PLAY_AUDIO_MSF, &play, sizeof(play),
                          NULL, 0, &br, NULL)) {
        wmcda->hCallback = NULL;
        ret = MCIERR_HARDWARE;
@@ -1087,7 +1111,7 @@ static DWORD MCICDA_Stop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms
         IDirectSound_Release(wmcda->dsObj);
         wmcda->dsObj = NULL;
     }
-    else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL))
+    else if (!device_io(wmcda->handle, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL))
         return MCIERR_HARDWARE;
 
     if ((dwFlags & MCI_NOTIFY) && lpParms)
@@ -1117,7 +1141,7 @@ static DWORD MCICDA_Pause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParm
            FAILED(IDirectSoundBuffer_Stop(wmcda->dsBuf)))
             return MCIERR_HARDWARE;
     }
-    else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL))
+    else if (!device_io(wmcda->handle, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL))
         return MCIERR_HARDWARE;
 
     if ((dwFlags & MCI_NOTIFY) && lpParms)
@@ -1143,7 +1167,7 @@ static DWORD MCICDA_Resume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpPar
            FAILED(IDirectSoundBuffer_Play(wmcda->dsBuf, 0, 0, DSBPLAY_LOOPING)))
             return MCIERR_HARDWARE;
     }
-    else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_RESUME_AUDIO, NULL, 0, NULL, 0, &br, NULL))
+    else if (!device_io(wmcda->handle, IOCTL_CDROM_RESUME_AUDIO, NULL, 0, NULL, 0, &br, NULL))
         return MCIERR_HARDWARE;
 
     if ((dwFlags & MCI_NOTIFY) && lpParms)
@@ -1176,7 +1200,7 @@ static DWORD MCICDA_Seek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
      * then only checks the position flags, then stops and seeks. */
     MCICDA_Stop(wDevID, MCI_WAIT, 0);
 
-    if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
+    if (!device_io(wmcda->handle, IOCTL_CDROM_READ_TOC, NULL, 0,
                          &toc, sizeof(toc), &br, NULL)) {
         WARN("error reading TOC !\n");
         return MCICDA_GetError(wmcda);
@@ -1210,7 +1234,7 @@ static DWORD MCICDA_Seek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
         seek.M = at / CDFRAMES_PERMIN;
         seek.S = (at / CDFRAMES_PERSEC) % 60;
         seek.F = at % CDFRAMES_PERSEC;
-        if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_SEEK_AUDIO_MSF, &seek, sizeof(seek),
+        if (!device_io(wmcda->handle, IOCTL_CDROM_SEEK_AUDIO_MSF, &seek, sizeof(seek),
                              NULL, 0, &br, NULL))
             return MCIERR_HARDWARE;
     }
@@ -1232,7 +1256,7 @@ static DWORD      MCICDA_SetDoor(UINT wDevID, BOOL open)
 
     if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID;
 
-    if (!DeviceIoControl(wmcda->handle,
+    if (!device_io(wmcda->handle,
                          (open) ? IOCTL_STORAGE_EJECT_MEDIA : IOCTL_STORAGE_LOAD_MEDIA,
                          NULL, 0, NULL, 0, &br, NULL))
        return MCIERR_HARDWARE;
index 0726de2..a7abad0 100644 (file)
@@ -94,7 +94,7 @@ reactos/dll/win32/localui             # Synced to WineStaging-1.7.47
 reactos/dll/win32/lz32                # Synced to WineStaging-1.7.47
 reactos/dll/win32/mapi32              # Synced to WineStaging-1.7.47
 reactos/dll/win32/mciavi32            # Synced to WineStaging-1.7.55
-reactos/dll/win32/mcicda              # Synced to WineStaging-1.7.47
+reactos/dll/win32/mcicda              # Synced to WineStaging-1.7.55
 reactos/dll/win32/mciqtz32            # Synced to WineStaging-1.7.47
 reactos/dll/win32/mciseq              # Synced to WineStaging-1.7.47
 reactos/dll/win32/mciwave             # Synced to WineStaging-1.7.47