Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Mon, May 14, 2018 at 09:24:08PM +0900, Akihiro Sagawa wrote:
Fix Bug 44974. This is a regression introduced by 185d98bbfdbf7ef10ef52d0264a5a38aedd3b19d. 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
dlls/winmm/tests/midi.c | 18 ++++++++++++++++-- dlls/winmm/winmm.c | 13 +++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c index b0efe16..b62b461 100644 --- a/dlls/winmm/tests/midi.c +++ b/dlls/winmm/tests/midi.c @@ -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) diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index b97580e..e0a2360 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -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,
if(!ret) HeapFree(GetProcessHeap(), 0, lpMidiStrm);lpwm->mod.dwInstance, 0, 0);
@@ -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,
return ret;lpwm->mod.dwInstance, 0, 0);
}