Jörg Höhle : mcicda: Opens d, d:, d:\, d: \foo since w2k. Only d: is portable.

Alexandre Julliard julliard at winehq.org
Wed Aug 25 12:35:07 CDT 2010


Module: wine
Branch: master
Commit: 5bff616faa3ce967d2222eda4d2f9700ebf9e130
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5bff616faa3ce967d2222eda4d2f9700ebf9e130

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Fri Aug 13 14:58:55 2010 +0200

mcicda: Opens d, d:, d:\, d:\foo since w2k. Only d: is portable.

---

 dlls/mcicda/mcicda.c      |   14 +++++++-------
 dlls/winmm/tests/mcicda.c |   44 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/dlls/mcicda/mcicda.c b/dlls/mcicda/mcicda.c
index 51727ee..0334f2e 100644
--- a/dlls/mcicda/mcicda.c
+++ b/dlls/mcicda/mcicda.c
@@ -428,23 +428,23 @@ static DWORD MCICDA_Open(UINT wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSW lpOpenPar
     if (dwFlags & MCI_OPEN_ELEMENT) {
         if (dwFlags & MCI_OPEN_ELEMENT_ID) {
             WARN("MCI_OPEN_ELEMENT_ID %p! Abort\n", lpOpenParms->lpstrElementName);
-            ret = MCIERR_NO_ELEMENT_ALLOWED;
+            ret = MCIERR_FLAGS_NOT_COMPATIBLE;
             goto the_error;
         }
         TRACE("MCI_OPEN_ELEMENT element name: %s\n", debugstr_w(lpOpenParms->lpstrElementName));
-        if (!isalpha(lpOpenParms->lpstrElementName[0]) || lpOpenParms->lpstrElementName[1] != ':' ||
-            (lpOpenParms->lpstrElementName[2] && lpOpenParms->lpstrElementName[2] != '\\'))
+        /* Only the first letter counts since w2k
+         * Win9x-NT accept only d: and w98SE accepts d:\foobar as well.
+         * Play d:\Track03.cda plays from the first track, not #3. */
+        if (!isalpha(lpOpenParms->lpstrElementName[0]))
         {
-            WARN("MCI_OPEN_ELEMENT unsupported format: %s\n", 
-                 debugstr_w(lpOpenParms->lpstrElementName));
-            ret = MCIERR_NO_ELEMENT_ALLOWED;
+            ret = MCIERR_INVALID_FILE;
             goto the_error;
         }
         drive = toupper(lpOpenParms->lpstrElementName[0]);
         root[0] = drive; root[1] = ':'; root[2] = '\\'; root[3] = '\0';
         if (GetDriveTypeW(root) != DRIVE_CDROM)
         {
-            ret = MCIERR_INVALID_DEVICE_NAME;
+            ret = MCIERR_INVALID_FILE;
             goto the_error;
         }
     }
diff --git a/dlls/winmm/tests/mcicda.c b/dlls/winmm/tests/mcicda.c
index 14484a5..3dc610a 100644
--- a/dlls/winmm/tests/mcicda.c
+++ b/dlls/winmm/tests/mcicda.c
@@ -26,6 +26,7 @@
 typedef union {
       MCI_STATUS_PARMS     status;
       MCI_GETDEVCAPS_PARMS caps;
+      MCI_OPEN_PARMS       open;
       MCI_PLAY_PARMS       play;
       MCI_SEEK_PARMS       seek;
       MCI_SAVE_PARMS       save;
@@ -151,8 +152,6 @@ static DWORD MSF_Add(DWORD d1, DWORD d2)
     return MCI_MAKE_MSF(m,s,f);
 }
 
-/* TODO test_open "open X: type cdaudio" etc. */
-/* TODO demonstrate open X:\ fails on win95 while open X: works. */
 /* TODO show that shareable flag is not what Wine implements. */
 
 static void test_play(HWND hwnd)
@@ -607,6 +606,46 @@ static void test_play(HWND hwnd)
     test_notification(hwnd, "STOP final", 0);
 }
 
+static void test_openclose(HWND hwnd)
+{
+    MCIDEVICEID wDeviceID;
+    MCI_PARMS_UNION parm;
+    MCIERROR err;
+    char drive[] = {'a',':','\\','X','\0'};
+
+    /* Bug in native since NT: After OPEN "c" without MCI_OPEN_ALIAS fails with
+     * MCIERR_DEVICE_OPEN, any subsequent OPEN fails with EXTENSION_NOT_FOUND! */
+    parm.open.lpstrAlias = "x"; /* with alias, OPEN "c" behaves normally */
+    parm.open.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;
+    parm.open.lpstrElementName = drive;
+    for ( ; strlen(drive); drive[strlen(drive)-1] = 0)
+    for (drive[0] = 'a'; drive[0] <= 'z'; drive[0]++) {
+        err = mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT | MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID
+                              | MCI_OPEN_SHAREABLE | MCI_OPEN_ALIAS, (DWORD_PTR)&parm);
+        ok(!err || err == MCIERR_INVALID_FILE, "OPEN %s type: %s\n", drive, dbg_mcierr(err));
+        /* open X:\ fails in Win9x/NT. Only open X: works everywhere. */
+        if(!err) {
+            wDeviceID = parm.open.wDeviceID;
+            trace("ok with %s\n", drive);
+            err = mciSendCommand(wDeviceID, MCI_CLOSE, 0, 0);
+            ok(!err,"mciCommand close returned %s\n", dbg_mcierr(err));
+        }
+    }
+    drive[0] = '\\';
+    err = mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID
+                          | MCI_OPEN_SHAREABLE, (DWORD_PTR)&parm);
+    ok(err == MCIERR_INVALID_FILE, "OPEN %s type: %s\n", drive, dbg_mcierr(err));
+    if(!err) mciSendCommand(parm.open.wDeviceID, MCI_CLOSE, 0, 0);
+
+    if (0) {
+        parm.open.lpstrElementName = (LPCSTR)0xDEADBEEF;
+        err = mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT|MCI_OPEN_ELEMENT_ID
+                              | MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, (DWORD_PTR)&parm);
+        todo_wine ok(err == MCIERR_FLAGS_NOT_COMPATIBLE, "OPEN elt_ID: %s\n", dbg_mcierr(err));
+        if(!err) mciSendCommand(parm.open.wDeviceID, MCI_CLOSE, 0, 0);
+    }
+}
+
 START_TEST(mcicda)
 {
     MCIERROR err;
@@ -615,6 +654,7 @@ START_TEST(mcicda)
                            0, 0, 0, NULL);
     test_notification(hwnd, "-prior to tests-", 0);
     test_play(hwnd);
+    test_openclose(hwnd);
     err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_STOP, 0, 0);
     todo_wine ok(!err || broken(err == MCIERR_HARDWARE /* blank CD or testbot without CD-ROM */),
        "STOP all returned %s\n", dbg_mcierr(err));




More information about the wine-cvs mailing list