Commit d727596a authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

winealsa.drv: Fix F0 and F7 byte insertion + memory leak and remove LP stuff in modLongData.

parent d7ac251e
...@@ -932,7 +932,7 @@ static DWORD modData(WORD wDevID, DWORD dwParam) ...@@ -932,7 +932,7 @@ static DWORD modData(WORD wDevID, DWORD dwParam)
static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
{ {
int len_add = 0; int len_add = 0;
LPBYTE lpData, lpNewData = NULL; BYTE *lpData, *lpNewData = NULL;
snd_seq_event_t event; snd_seq_event_t event;
TRACE("(%04X, %p, %08X);\n", wDevID, lpMidiHdr, dwSize); TRACE("(%04X, %p, %08X);\n", wDevID, lpMidiHdr, dwSize);
...@@ -950,7 +950,7 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) ...@@ -950,7 +950,7 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
return MIDIERR_NODEVICE; return MIDIERR_NODEVICE;
} }
lpData = (LPBYTE) lpMidiHdr->lpData; lpData = (BYTE*)lpMidiHdr->lpData;
if (lpData == NULL) if (lpData == NULL)
return MIDIERR_UNPREPARED; return MIDIERR_UNPREPARED;
...@@ -979,23 +979,23 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) ...@@ -979,23 +979,23 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
switch (MidiOutDev[wDevID].caps.wTechnology) { switch (MidiOutDev[wDevID].caps.wTechnology) {
case MOD_FMSYNTH: case MOD_FMSYNTH:
/* FIXME: I don't think there is much to do here */ /* FIXME: I don't think there is much to do here */
HeapFree(GetProcessHeap(), 0, lpNewData);
break; break;
case MOD_MIDIPORT: case MOD_MIDIPORT:
if (lpData[0] != 0xF0) { if (lpData[0] != 0xF0) {
/* Send start of System Exclusive */ /* Send start of System Exclusive */
len_add = 1; len_add = 1;
lpData[0] = 0xF0; lpNewData[0] = 0xF0;
memcpy(lpNewData, lpData, lpMidiHdr->dwBufferLength); memcpy(lpNewData + 1, lpData, lpMidiHdr->dwBufferLength);
WARN("Adding missing 0xF0 marker at the beginning of " WARN("Adding missing 0xF0 marker at the beginning of system exclusive byte stream\n");
"system exclusive byte stream\n");
} }
if (lpData[lpMidiHdr->dwBufferLength-1] != 0xF7) { if (lpData[lpMidiHdr->dwBufferLength-1] != 0xF7) {
/* Send end of System Exclusive */ /* Send end of System Exclusive */
memcpy(lpData + len_add, lpData, lpMidiHdr->dwBufferLength); if (!len_add)
lpNewData[lpMidiHdr->dwBufferLength + len_add - 1] = 0xF0; memcpy(lpNewData, lpData, lpMidiHdr->dwBufferLength);
lpNewData[lpMidiHdr->dwBufferLength + len_add] = 0xF7;
len_add++; len_add++;
WARN("Adding missing 0xF7 marker at the end of " WARN("Adding missing 0xF7 marker at the end of system exclusive byte stream\n");
"system exclusive byte stream\n");
} }
snd_seq_ev_clear(&event); snd_seq_ev_clear(&event);
snd_seq_ev_set_direct(&event); snd_seq_ev_set_direct(&event);
...@@ -1004,8 +1004,7 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) ...@@ -1004,8 +1004,7 @@ static DWORD modLongData(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize)
TRACE("client = %d port = %d\n", MidiOutDev[wDevID].addr.client, MidiOutDev[wDevID].addr.port); TRACE("client = %d port = %d\n", MidiOutDev[wDevID].addr.client, MidiOutDev[wDevID].addr.port);
snd_seq_ev_set_sysex(&event, lpMidiHdr->dwBufferLength + len_add, lpNewData ? lpNewData : lpData); snd_seq_ev_set_sysex(&event, lpMidiHdr->dwBufferLength + len_add, lpNewData ? lpNewData : lpData);
snd_seq_event_output_direct(midiSeq, &event); snd_seq_event_output_direct(midiSeq, &event);
if (lpNewData) HeapFree(GetProcessHeap(), 0, lpNewData);
HeapFree(GetProcessHeap(), 0, lpData);
break; break;
default: default:
WARN("Technology not supported (yet) %d !\n", WARN("Technology not supported (yet) %d !\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment