From 294d0c9501c68e6b07a9cce5ed51d5ac5d53ca5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20H=C3=B6hle?= Date: Wed, 1 Sep 2010 20:57:24 +0200 Subject: [PATCH] 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 6724d7fa4c4..c7e816517ee 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 e951fbf1ee1..f47d4f6f66b 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