diff --git a/dlls/winmm/driver.c b/dlls/winmm/driver.c index 8620fe698f2..feecc921220 100644 --- a/dlls/winmm/driver.c +++ b/dlls/winmm/driver.c @@ -129,7 +129,7 @@ LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr) static inline LRESULT DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, LPARAM lParam1, LPARAM lParam2) { - LRESULT ret = 0; + LRESULT ret; TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n", lpDrv->lpDrvProc, lpDrv->dwDriverID, lpDrv, msg, lParam1, lParam2); @@ -552,24 +552,28 @@ BOOL WINAPI DriverCallback(DWORD_PTR dwCallBack, DWORD uFlags, HDRVR hDev, DWORD wMsg, DWORD_PTR dwUser, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { + BOOL ret = FALSE; TRACE("(%08lX, %s %04X, %p, %04X, %08lX, %08lX, %08lX)\n", dwCallBack, DRIVER_getCallback(uFlags), uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2); + if (!dwCallBack) + return ret; switch (uFlags & DCB_TYPEMASK) { case DCB_NULL: - break; + /* Native returns FALSE = no notification, not TRUE */ + return ret; case DCB_WINDOW: - PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1); + ret = PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1); break; case DCB_TASK: /* aka DCB_THREAD */ - PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1); + ret = PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1); break; case DCB_FUNCTION: - if (dwCallBack) - ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2); + ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2); + ret = TRUE; break; case DCB_EVENT: - SetEvent((HANDLE)dwCallBack); + ret = SetEvent((HANDLE)dwCallBack); break; #if 0 /* FIXME: for now only usable in mmsystem.dll16 @@ -601,8 +605,11 @@ BOOL WINAPI DriverCallback(DWORD_PTR dwCallBack, DWORD uFlags, HDRVR hDev, WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK); return FALSE; } - TRACE("Done\n"); - return TRUE; + if (ret) + TRACE("Done\n"); + else + WARN("Notification failure\n"); + return ret; } /****************************************************************** diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c index e40e1d746de..f02c4f0fd15 100644 --- a/dlls/winmm/tests/midi.c +++ b/dlls/winmm/tests/midi.c @@ -325,6 +325,19 @@ static void test_midiOut_device(UINT udev, HWND hwnd) rc = midiOutClose(hm); ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc)); test_notification(hwnd, "midiOutClose", MOM_CLOSE, 0); + + rc = midiOutOpen(&hm, udev, 0, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW); + ok(!rc, "midiOutOpen(dev=%d) 0 CALLBACK_WINDOW rc=%s\n", udev, mmsys_error(rc)); + /* PostMessage(hwnd=0) redirects to PostThreadMessage(GetCurrentThreadId()) + * which PeekMessage((HWND)-1) queries. */ + test_notification((HWND)-1, "midiOutOpen WINDOW->THREAD", 0, WHATEVER); + test_notification(hwnd, "midiOutOpen WINDOW", 0, WHATEVER); + if (!rc) { + rc = midiOutClose(hm); + ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc)); + test_notification((HWND)-1, "midiOutClose WINDOW->THREAD", 0, WHATEVER); + test_notification(hwnd, "midiOutClose", 0, WHATEVER); + } test_notification(hwnd, "midiOut over", 0, WHATEVER); }