Jörg Höhle : winmm: Implement MCIERR_DUPLICATE_ALIAS and MCIERR_DEVICE_OPEN.

Alexandre Julliard julliard at winehq.org
Fri Sep 3 10:07:10 CDT 2010


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

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Wed Sep  1 20:57:24 2010 +0200

winmm: Implement MCIERR_DUPLICATE_ALIAS and MCIERR_DEVICE_OPEN.

---

 dlls/winmm/mci.c       |    8 ++++++--
 dlls/winmm/tests/mci.c |   13 ++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c
index 6724d7f..c7e8165 100644
--- a/dlls/winmm/mci.c
+++ b/dlls/winmm/mci.c
@@ -898,14 +898,18 @@ static	DWORD	MCI_FinishOpen(LPWINE_MCIDRIVER wmd, LPMCI_OPEN_PARMSW lpParms,
 {
     LPCWSTR alias = NULL;
     /* Open always defines an alias for further reference */
-    if (dwParam & MCI_OPEN_ALIAS)           /* open ... alias */
+    if (dwParam & MCI_OPEN_ALIAS) {         /* open ... alias */
         alias = lpParms->lpstrAlias;
-    else {
+        if (MCI_GetDriverFromString(alias))
+            return MCIERR_DUPLICATE_ALIAS;
+    } else {
         if ((dwParam & MCI_OPEN_ELEMENT)    /* open file.wav */
             && !(dwParam & MCI_OPEN_ELEMENT_ID))
             alias = lpParms->lpstrElementName;
         else if (dwParam & MCI_OPEN_TYPE )  /* open cdaudio */
             alias = wmd->lpstrDeviceType;
+        if (alias && MCI_GetDriverFromString(alias))
+            return MCIERR_DEVICE_OPEN;
     }
     if (alias) {
         wmd->lpstrAlias = HeapAlloc(GetProcessHeap(), 0, (strlenW(alias)+1) * sizeof(WCHAR));
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index e951fbf..f47d4f6 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -525,6 +525,11 @@ static void test_openCloseWAVE(HWND hwnd)
     err = mciGetDeviceID("waveaudio");
     ok(err==1,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
 
+    err = mciSendString("open no-such-file.wav alias waveaudio", buf, sizeof(buf), NULL);
+    ok(err==MCIERR_DUPLICATE_ALIAS, "mci open alias waveaudio returned %s\n", dbg_mcierr(err));
+    /* If it were not already in use, open avivideo alias waveaudio would succeed,
+     * making for funny test cases. */
+
     err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0); /* from MSDN */
     ok(!err,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0) returned %s\n", dbg_mcierr(err));
 
@@ -1124,10 +1129,12 @@ static void test_AutoOpenWAVE(HWND hwnd)
     ok(!err,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err));
     if(!err) ok(!strcmp(buf,"playing"), "mci auto-open status mode, got: %s\n", buf);
 
-    if (0) { /* FIXME: wait until this no more confuses Wine */
     err = mciSendString("open tempfile.wav", buf, sizeof(buf), NULL);
-    todo_wine ok(err==MCIERR_DEVICE_OPEN, "mci open from auto-open returned %s\n", dbg_mcierr(err));
-    }
+    ok(err==MCIERR_DEVICE_OPEN, "mci open from auto-open returned %s\n", dbg_mcierr(err));
+
+    err = mciSendString("open foo.wav alias tempfile.wav", buf, sizeof(buf), NULL);
+    ok(err==MCIERR_DUPLICATE_ALIAS, "mci open re-using alias returned %s\n", dbg_mcierr(err));
+
     /* w2k/xp and Wine differ. While the device is busy playing, it is
      * regularly open and accessible via the filename: subsequent
      * commands must not cause auto-open each.  In Wine, a subsequent




More information about the wine-cvs mailing list