winmm: Fix superfluous MOM_DONE callback messages.

This is a regression introduced by 185d98bbfd.
Because midiOutLongMsg's MOM_DONE callback message confuses an application,
we don't rely on midiOut callback routine anymore in MIDI stream processing.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2018-05-14 21:24:08 +09:00 committed by Alexandre Julliard
parent 883df92aa1
commit 1c38d47e4d
2 changed files with 27 additions and 4 deletions

View File

@ -433,8 +433,12 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
return;
}
rc = midiOutOpen(&hm, udev, 0, (DWORD_PTR)0, CALLBACK_NULL);
if (hwnd)
rc = midiOutOpen(&hm, udev, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
else
rc = midiOutOpen(&hm, udev, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
ok(!rc, "midiOutOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
test_notification(hwnd, "midiOutOpen", MOM_OPEN, 0);
memset(&mhdr, 0, sizeof(mhdr));
mhdr.lpData = (LPSTR)SysEx_reset;
@ -445,6 +449,7 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
ok(!rc, "midiOutLongMsg rc=%s\n", mmsys_error(rc));
rc = midiOutUnprepareHeader(hm, &mhdr, sizeof(mhdr));
ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiOutLongMsg", MOM_DONE, (DWORD_PTR)&mhdr);
Sleep(60);
mhdr.lpData = (LPSTR)SysEx_volume_off;
@ -455,6 +460,7 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
ok(!rc, "midiOutLongMsg rc=%s\n", mmsys_error(rc));
rc = midiOutUnprepareHeader(hm, &mhdr, sizeof(mhdr));
ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiOutLongMsg", MOM_DONE, (DWORD_PTR)&mhdr);
{
DWORD e = 0x006F4593; /* velocity 111, note #69, channel 4 */
@ -476,9 +482,11 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
ok(!rc, "midiOutLongMsg rc=%s\n", mmsys_error(rc));
rc = midiOutUnprepareHeader(hm, &mhdr, sizeof(mhdr));
ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiOutLongMsg", MOM_DONE, (DWORD_PTR)&mhdr);
rc = midiOutClose(hm);
ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiOuClose", MOM_CLOSE, 0);
}
static void test_position(HMIDISTRM hm, UINT typein, UINT typeout)
@ -789,8 +797,12 @@ static void test_midiStream(UINT udev, HWND hwnd)
#define ROUNDUP4(n) (((n) + 3) & ~3)
hm = NULL;
rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)0, (DWORD_PTR)0, CALLBACK_NULL);
if (hwnd)
rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
else
rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
ok(!rc, "midiOutOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
test_notification(hwnd, "midiStreamOpen", MOM_OPEN, 0);
midiprop.tdiv.cbStruct = sizeof(midiprop.tdiv);
midiprop.tdiv.dwTimeDiv = 480;
@ -841,6 +853,7 @@ static void test_midiStream(UINT udev, HWND hwnd)
rc = playStream(hm, &mhdr);
ok(!rc, "midiStreamOut rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiStreamOut", MOM_DONE, (DWORD_PTR)&mhdr);
rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
@ -849,6 +862,7 @@ static void test_midiStream(UINT udev, HWND hwnd)
}
rc = midiStreamClose(hm);
ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc));
test_notification(hwnd, "midiStreamClose", MOM_CLOSE, 0);
}
static BOOL scan_subkeys(HKEY parent, const LPCSTR *sub_keys)

View File

@ -1224,12 +1224,13 @@ the_end:
*/
MMRESULT WINAPI midiStreamClose(HMIDISTRM hMidiStrm)
{
WINE_MIDI* lpwm;
WINE_MIDIStream* lpMidiStrm;
MMRESULT ret = 0;
TRACE("(%p)!\n", hMidiStrm);
if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, NULL))
if (!MMSYSTEM_GetMidiStream(hMidiStrm, &lpMidiStrm, &lpwm))
return MMSYSERR_INVALHANDLE;
midiStreamStop(hMidiStrm);
@ -1244,6 +1245,9 @@ MMRESULT WINAPI midiStreamClose(HMIDISTRM hMidiStrm)
}
CloseHandle(lpMidiStrm->hThread);
}
DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags,
(HDRVR)lpMidiStrm->hDevice, MM_MOM_CLOSE,
lpwm->mod.dwInstance, 0, 0);
if(!ret)
HeapFree(GetProcessHeap(), 0, lpMidiStrm);
@ -1294,7 +1298,8 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
lpwm->mld.uDeviceID = *lpuDeviceID;
ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD_PTR)&lpwm->mod, fdwOpen);
/* don't rely on midiOut callbacks */
ret = MMDRV_Open(&lpwm->mld, MODM_OPEN, (DWORD_PTR)&lpwm->mod, CALLBACK_NULL);
if (ret != MMSYSERR_NOERROR) {
MMDRV_Free(hMidiOut, &lpwm->mld);
HeapFree(GetProcessHeap(), 0, lpMidiStrm);
@ -1320,6 +1325,10 @@ MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
TRACE("=> (%u/%d) hMidi=%p ret=%d lpMidiStrm=%p\n",
*lpuDeviceID, lpwm->mld.uDeviceID, *lphMidiStrm, ret, lpMidiStrm);
DriverCallback(lpwm->mod.dwCallback, lpMidiStrm->wFlags,
(HDRVR)lpMidiStrm->hDevice, MM_MOM_OPEN,
lpwm->mod.dwInstance, 0, 0);
return ret;
}