winmm: Implement MCIERR_DUPLICATE_ALIAS and MCIERR_DEVICE_OPEN.

This commit is contained in:
Jörg Höhle 2010-09-01 20:57:24 +02:00 committed by Alexandre Julliard
parent 6b271b6d3c
commit 294d0c9501
2 changed files with 16 additions and 5 deletions

View File

@ -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));

View File

@ -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