Jörg Höhle : winmm: Improve MCI's Sysinfo command .
Alexandre Julliard
julliard at winehq.org
Thu Apr 1 11:25:05 CDT 2010
Module: wine
Branch: master
Commit: f70b2f54935d6aff2b5464131e3f4a004f42aa18
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f70b2f54935d6aff2b5464131e3f4a004f42aa18
Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date: Tue Nov 17 22:07:55 2009 +0100
winmm: Improve MCI's Sysinfo command.
---
dlls/winmm/mci.c | 55 +++++++++++++++++++++++++++++++++++++++--------
dlls/winmm/tests/mci.c | 6 ++--
2 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c
index 54e9e19..4fbb9a0 100644
--- a/dlls/winmm/mci.c
+++ b/dlls/winmm/mci.c
@@ -1733,10 +1733,16 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
TRACE("(%08x, %08X, %p[num=%d, wDevTyp=%u])\n",
uDevID, dwFlags, lpParms, lpParms->dwNumber, lpParms->wDeviceType);
+ if ((WORD)MCI_ALL_DEVICE_ID == LOWORD(uDevID))
+ uDevID = MCI_ALL_DEVICE_ID; /* Be compatible with Win9x */
- switch (dwFlags & ~MCI_SYSINFO_OPEN) {
+ switch (dwFlags & ~(MCI_SYSINFO_OPEN|MCI_NOTIFY|MCI_WAIT)) {
case MCI_SYSINFO_QUANTITY:
- if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
+ if (lpParms->dwRetSize < sizeof(DWORD))
+ return MCIERR_PARAM_OVERFLOW;
+ /* Win9x returns 0 for 0 < uDevID < (UINT16)MCI_ALL_DEVICE_ID */
+ if (uDevID == MCI_ALL_DEVICE_ID) {
+ /* wDeviceType == MCI_ALL_DEVICE_ID is not recognized. */
if (dwFlags & MCI_SYSINFO_OPEN) {
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
EnterCriticalSection(&WINMM_cs);
@@ -1756,14 +1762,14 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
}
} else {
if (dwFlags & MCI_SYSINFO_OPEN) {
- TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", lpParms->wDeviceType);
+ TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %d\n", lpParms->wDeviceType);
EnterCriticalSection(&WINMM_cs);
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
if (wmd->wType == lpParms->wDeviceType) cnt++;
}
LeaveCriticalSection(&WINMM_cs);
} else {
- TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", lpParms->wDeviceType);
+ TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %d\n", lpParms->wDeviceType);
FIXME("Don't know how to get # of MCI devices of a given type\n");
cnt = 1;
}
@@ -1771,6 +1777,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
*(DWORD*)lpParms->lpstrReturn = cnt;
TRACE("(%d) => '%d'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn);
ret = MCI_INTEGER_RETURNED;
+ /* return ret; Only Win9x sends a notification in this case. */
break;
case MCI_SYSINFO_INSTALLNAME:
TRACE("MCI_SYSINFO_INSTALLNAME\n");
@@ -1784,12 +1791,27 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
TRACE("(%d) => %s\n", lpParms->dwNumber, debugstr_w(lpParms->lpstrReturn));
break;
case MCI_SYSINFO_NAME:
- TRACE("MCI_SYSINFO_NAME\n");
+ s = NULL;
if (dwFlags & MCI_SYSINFO_OPEN) {
- FIXME("Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n");
- ret = MCIERR_UNRECOGNIZED_COMMAND;
- } else {
- s = NULL;
+ /* Win9x returns 0 for 0 < uDevID < (UINT16)MCI_ALL_DEVICE_ID */
+ TRACE("MCI_SYSINFO_NAME: nth alias of type %d\n",
+ uDevID == MCI_ALL_DEVICE_ID ? MCI_ALL_DEVICE_ID : lpParms->wDeviceType);
+ EnterCriticalSection(&WINMM_cs);
+ for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
+ /* wDeviceType == MCI_ALL_DEVICE_ID is not recognized. */
+ if (uDevID == MCI_ALL_DEVICE_ID ||
+ lpParms->wDeviceType == wmd->wType) {
+ cnt++;
+ if (cnt == lpParms->dwNumber) {
+ s = wmd->lpstrAlias;
+ break;
+ }
+ }
+ }
+ LeaveCriticalSection(&WINMM_cs);
+ ret = s ? MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize / sizeof(WCHAR), s) : MCIERR_OUTOFRANGE;
+ } else if (MCI_ALL_DEVICE_ID == uDevID) {
+ TRACE("MCI_SYSINFO_NAME: device #%d\n", lpParms->dwNumber);
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, wszHklmMci, 0,
KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
if (RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt,
@@ -1814,13 +1836,26 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
}
}
ret = s ? MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize / sizeof(WCHAR), s) : MCIERR_OUTOFRANGE;
+ } else {
+ FIXME("MCI_SYSINFO_NAME: nth device of type %d\n", lpParms->wDeviceType);
+ /* Cheating: what is asked for is the nth device from the registry. */
+ if (1 != lpParms->dwNumber || /* Handle only one of each kind. */
+ lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST)
+ ret = MCIERR_OUTOFRANGE;
+ else {
+ LoadStringW(hWinMM32Instance, LOWORD(lpParms->wDeviceType),
+ lpParms->lpstrReturn, lpParms->dwRetSize / sizeof(WCHAR));
+ ret = 0;
+ }
}
TRACE("(%d) => %s\n", lpParms->dwNumber, debugstr_w(lpParms->lpstrReturn));
break;
default:
TRACE("Unsupported flag value=%08x\n", dwFlags);
- ret = MCIERR_UNRECOGNIZED_COMMAND;
+ ret = MCIERR_UNRECOGNIZED_KEYWORD;
}
+ if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0)
+ mciDriverNotify((HWND)lpParms->dwCallback, uDevID, MCI_NOTIFY_SUCCESSFUL);
return ret;
}
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index 6bdfefe..a289fd6 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -230,7 +230,7 @@ static void test_openCloseWAVE(HWND hwnd)
memset(buf, 0, sizeof(buf));
err = mciSendString(command_sysinfo, buf, sizeof(buf), NULL);
ok(!err,"mci %s returned %s\n", command_sysinfo, dbg_mcierr(err));
- todo_wine ok(buf[0] == '0' && buf[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo, buf);
+ ok(buf[0] == '0' && buf[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo, buf);
err = mciSendString("open new type waveaudio", buf, sizeof(buf), NULL);
ok(err==MCIERR_NEW_REQUIRES_ALIAS,"mci open new without alias returned %s\n", dbg_mcierr(err));
@@ -724,7 +724,7 @@ static void test_AutoOpenWAVE(HWND hwnd)
err = mciSendString("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
ok(!err,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err));
- if(!err) todo_wine ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf);
+ if(!err) ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf);
/* Who knows why some machines pass all tests but return MCIERR_HARDWARE here? */
err = mciSendString("sound NoSuchSoundDefined wait", NULL, 0, NULL);
@@ -736,7 +736,7 @@ static void test_AutoOpenWAVE(HWND hwnd)
buf[0]=0;
err = mciSendString("sysinfo waveaudio name 1 open", buf, sizeof(buf), NULL);
- todo_wine ok(err==MCIERR_OUTOFRANGE,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err));
+ ok(err==MCIERR_OUTOFRANGE,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err));
if(!err) trace("sysinfo dangling open alias: %s\n", buf);
err = mciSendString("play no-such-file-exists.wav notify", buf, sizeof(buf), NULL);
More information about the wine-cvs
mailing list