>From b8b97bb56dd6460b2b422061cc565dafe9d94d46 Mon Sep 17 00:00:00 2001 From: Johannes Kroll Date: Wed, 9 Jan 2013 02:40:34 +0100 Subject: terminate sysex messages --- dlls/winmm/winmm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index aecb9cf..f4fecb1 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -531,11 +531,28 @@ UINT WINAPI midiOutLongMsg(HMIDIOUT hMidiOut, MIDIHDR* lpMidiOutHdr, UINT uSize) { LPWINE_MLD wmld; + int i; TRACE("(%p, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize); if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; + + for(i = 0; i < lpMidiOutHdr->dwBufferLength; i++) + { + /* SysEx messages are terminated by a 0xF7 byte. If the buffer contains additional + bytes, send only the bytes up to the termination byte. */ + if((unsigned char)lpMidiOutHdr->lpData[i] == 0xF7 && i < lpMidiOutHdr->dwBufferLength-1) + { + DWORD oldBufferLength = lpMidiOutHdr->dwBufferLength; + DWORD ret; + lpMidiOutHdr->dwBufferLength = i+1; + ret = MMDRV_Message(wmld, MODM_LONGDATA, (DWORD_PTR)lpMidiOutHdr, uSize); + /* restore the midi header to its original state. */ + lpMidiOutHdr->dwBufferLength = oldBufferLength; + return ret; + } + } return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD_PTR)lpMidiOutHdr, uSize); } -- 1.7.9.5