winmm: Auto-open MCI core commands only.

This commit is contained in:
Jörg Höhle 2010-09-14 20:45:16 +02:00 committed by Alexandre Julliard
parent 8fb1e3eba2
commit b4cc03f3e3
2 changed files with 32 additions and 24 deletions

View File

@ -1242,9 +1242,6 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
static const WCHAR wszNew[] = {'n','e','w',0};
static const WCHAR wszSAliasS[] = {' ','a','l','i','a','s',' ',0};
static const WCHAR wszTypeS[] = {'t','y','p','e',' ',0};
static const WCHAR wszSysinfo[] = {'s','y','s','i','n','f','o',0};
static const WCHAR wszSound[] = {'s','o','u','n','d',0};
static const WCHAR wszBreak[] = {'b','r','e','a','k',0};
TRACE("(%s, %p, %d, %p)\n",
debugstr_w(lpstrCommand), lpstrRet, uRetLen, hwndCallback);
@ -1337,26 +1334,37 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
HeapFree(GetProcessHeap(), 0, devType);
if (dwRet)
goto errCleanUp;
} else if (!strcmpW(verb, wszSysinfo) || !strcmpW(verb, wszSound) || !strcmpW(verb, wszBreak)) {
/* Prevent auto-open for system commands. */
} else if ((MCI_ALL_DEVICE_ID != uDevID) && !(wmd = MCI_GetDriver(mciGetDeviceIDW(dev)))) {
/* auto open */
static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
WCHAR buf[138], retbuf[6];
snprintfW(buf, sizeof(buf)/sizeof(WCHAR), wszOpenWait, dev);
/* open via mciSendString handles quoting, dev!file syntax and alias creation */
if ((dwRet = mciSendStringW(buf, retbuf, sizeof(retbuf)/sizeof(WCHAR), 0)) != 0)
} else if ((MCI_ALL_DEVICE_ID != uDevID) && !(wmd = MCI_GetDriver(mciGetDeviceIDW(dev)))
&& (lpCmd = MCI_FindCommand(MCI_GetCommandTable(0), verb))) {
/* auto-open uses the core command table */
switch (MCI_GetMessage(lpCmd)) {
case MCI_SOUND: /* command does not use a device name */
case MCI_SYSINFO:
break;
case MCI_CLOSE: /* don't auto-open for close */
case MCI_BREAK: /* no auto-open for system commands */
dwRet = MCIERR_INVALID_DEVICE_NAME;
goto errCleanUp;
auto_open = strtoulW(retbuf, NULL, 10);
TRACE("auto-opened %u\n", auto_open);
break;
default:
{
static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
WCHAR buf[138], retbuf[6];
snprintfW(buf, sizeof(buf)/sizeof(WCHAR), wszOpenWait, dev);
/* open via mciSendString handles quoting, dev!file syntax and alias creation */
if ((dwRet = mciSendStringW(buf, retbuf, sizeof(retbuf)/sizeof(WCHAR), 0)) != 0)
goto errCleanUp;
auto_open = strtoulW(retbuf, NULL, 10);
TRACE("auto-opened %u for %s\n", auto_open, debugstr_w(dev));
/* FIXME: test for notify flag (how to preparse?) before opening */
/* FIXME: Accept only core commands yet parse them with the specific table */
wmd = MCI_GetDriver(auto_open);
if (!wmd) {
ERR("No auto-open device %d for %s\n", auto_open, debugstr_w(dev));
dwRet = MCIERR_INVALID_DEVICE_ID;
goto errCleanUp;
/* FIXME: test for notify flag (how to preparse?) before opening */
wmd = MCI_GetDriver(auto_open);
if (!wmd) {
ERR("No auto-open device %u\n", auto_open);
dwRet = MCIERR_INVALID_DEVICE_ID;
goto errCleanUp;
}
}
}
}

View File

@ -458,7 +458,7 @@ static void test_openCloseWAVE(HWND hwnd)
Sleep(5);
test_notification(hwnd, command_close_my, 0);
err = mciSendString("open no-such-file-exists.wav alias y", buf, sizeof(buf), NULL);
err = mciSendString("open no-such-file-exists.wav alias y buffer 6", buf, sizeof(buf), NULL);
ok(err==MCIERR_FILE_NOT_FOUND,"open no-such-file.wav returned %s\n", dbg_mcierr(err));
if(!err) {
err = mciSendString("close y", NULL, 0, NULL);
@ -485,7 +485,7 @@ static void test_openCloseWAVE(HWND hwnd)
/* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
err = mciSendString("close waveaudio", buf, sizeof(buf), NULL);
todo_wine ok(err==MCIERR_INVALID_DEVICE_NAME,"open nosuchdevice!name: %s\n", dbg_mcierr(err));
ok(err==MCIERR_INVALID_DEVICE_NAME,"close waveaudio: %s\n", dbg_mcierr(err));
err = mciSendString(command_close_all, NULL, 0, NULL);
ok(!err,"mci %s (without buffer) returned %s\n", command_close_all, dbg_mcierr(err));
@ -743,7 +743,7 @@ static void test_playWAVE(HWND hwnd)
todo_wine ok(!strcmp(buf,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf);
err = mciSendString("cue output", NULL, 0, NULL);
todo_wine ok(err==MCIERR_UNRECOGNIZED_COMMAND,"mci incorrect cue output returned %s\n", dbg_mcierr(err));
ok(err==MCIERR_UNRECOGNIZED_COMMAND,"mci incorrect cue output returned %s\n", dbg_mcierr(err));
/* Test MCI to the bones -- Some todo_wine from Cue and
* from Play from 0 to 0 are not worth fixing. */