mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
winmm: Prevent some MIDI race conditions.
This commit is contained in:
parent
702fe6738b
commit
b0fc000ce1
2 changed files with 22 additions and 32 deletions
|
@ -389,9 +389,9 @@ static DWORD WINAPI midRecThread(LPVOID arg)
|
||||||
* to handle the case where ALSA split the sysex into several events */
|
* to handle the case where ALSA split the sysex into several events */
|
||||||
if ((lpMidiHdr->dwBytesRecorded == lpMidiHdr->dwBufferLength) ||
|
if ((lpMidiHdr->dwBytesRecorded == lpMidiHdr->dwBufferLength) ||
|
||||||
(*(BYTE*)(lpMidiHdr->lpData + lpMidiHdr->dwBytesRecorded - 1) == 0xF7)) {
|
(*(BYTE*)(lpMidiHdr->lpData + lpMidiHdr->dwBytesRecorded - 1) == 0xF7)) {
|
||||||
|
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
||||||
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
||||||
lpMidiHdr->dwFlags |= MHDR_DONE;
|
lpMidiHdr->dwFlags |= MHDR_DONE;
|
||||||
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
|
||||||
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -478,6 +478,16 @@ static DWORD midOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
|
||||||
return MMSYSERR_ERROR;
|
return MMSYSERR_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MidiInDev[wDevID].wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
|
||||||
|
|
||||||
|
MidiInDev[wDevID].lpQueueHdr = NULL;
|
||||||
|
MidiInDev[wDevID].dwTotalPlayed = 0;
|
||||||
|
MidiInDev[wDevID].bufsize = 0x3FFF;
|
||||||
|
MidiInDev[wDevID].midiDesc = *lpDesc;
|
||||||
|
MidiInDev[wDevID].state = 0;
|
||||||
|
MidiInDev[wDevID].incLen = 0;
|
||||||
|
MidiInDev[wDevID].startTime = 0;
|
||||||
|
|
||||||
/* Connect our app port to the device port */
|
/* Connect our app port to the device port */
|
||||||
if (snd_seq_connect_from(midiSeq, port_in, MidiInDev[wDevID].addr.client, MidiInDev[wDevID].addr.port) < 0)
|
if (snd_seq_connect_from(midiSeq, port_in, MidiInDev[wDevID].addr.client, MidiInDev[wDevID].addr.port) < 0)
|
||||||
return MMSYSERR_NOTENABLED;
|
return MMSYSERR_NOTENABLED;
|
||||||
|
@ -497,16 +507,6 @@ static DWORD midOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
|
||||||
TRACE("Created thread for midi-in\n");
|
TRACE("Created thread for midi-in\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
MidiInDev[wDevID].wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
|
|
||||||
|
|
||||||
MidiInDev[wDevID].lpQueueHdr = NULL;
|
|
||||||
MidiInDev[wDevID].dwTotalPlayed = 0;
|
|
||||||
MidiInDev[wDevID].bufsize = 0x3FFF;
|
|
||||||
MidiInDev[wDevID].midiDesc = *lpDesc;
|
|
||||||
MidiInDev[wDevID].state = 0;
|
|
||||||
MidiInDev[wDevID].incLen = 0;
|
|
||||||
MidiInDev[wDevID].startTime = 0;
|
|
||||||
|
|
||||||
MIDI_NotifyClient(wDevID, MIM_OPEN, 0L, 0L);
|
MIDI_NotifyClient(wDevID, MIM_OPEN, 0L, 0L);
|
||||||
return MMSYSERR_NOERROR;
|
return MMSYSERR_NOERROR;
|
||||||
}
|
}
|
||||||
|
@ -644,12 +644,11 @@ static DWORD midReset(WORD wDevID)
|
||||||
|
|
||||||
EnterCriticalSection(&crit_sect);
|
EnterCriticalSection(&crit_sect);
|
||||||
while (MidiInDev[wDevID].lpQueueHdr) {
|
while (MidiInDev[wDevID].lpQueueHdr) {
|
||||||
MidiInDev[wDevID].lpQueueHdr->dwFlags &= ~MHDR_INQUEUE;
|
LPMIDIHDR lpMidiHdr = MidiInDev[wDevID].lpQueueHdr;
|
||||||
MidiInDev[wDevID].lpQueueHdr->dwFlags |= MHDR_DONE;
|
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
||||||
/* FIXME: when called from 16 bit, lpQueueHdr needs to be a segmented ptr */
|
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
||||||
MIDI_NotifyClient(wDevID, MIM_LONGDATA,
|
lpMidiHdr->dwFlags |= MHDR_DONE;
|
||||||
(DWORD_PTR)MidiInDev[wDevID].lpQueueHdr, dwTime);
|
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
||||||
MidiInDev[wDevID].lpQueueHdr = MidiInDev[wDevID].lpQueueHdr->lpNext;
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&crit_sect);
|
LeaveCriticalSection(&crit_sect);
|
||||||
|
|
||||||
|
@ -726,10 +725,6 @@ static DWORD modOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
|
||||||
WARN("bad dwFlags\n");
|
WARN("bad dwFlags\n");
|
||||||
return MMSYSERR_INVALFLAG;
|
return MMSYSERR_INVALFLAG;
|
||||||
}
|
}
|
||||||
if (!MidiOutDev[wDevID].bEnabled) {
|
|
||||||
TRACE("disabled wDevID\n");
|
|
||||||
return MMSYSERR_NOTENABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
MidiOutDev[wDevID].lpExtra = 0;
|
MidiOutDev[wDevID].lpExtra = 0;
|
||||||
|
|
||||||
|
|
|
@ -563,9 +563,9 @@ static void midReceiveChar(WORD wDevID, unsigned char value, DWORD dwTime)
|
||||||
}
|
}
|
||||||
if (sbfb && lpMidiHdr != NULL) {
|
if (sbfb && lpMidiHdr != NULL) {
|
||||||
lpMidiHdr = MidiInDev[wDevID].lpQueueHdr;
|
lpMidiHdr = MidiInDev[wDevID].lpQueueHdr;
|
||||||
|
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
||||||
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
||||||
lpMidiHdr->dwFlags |= MHDR_DONE;
|
lpMidiHdr->dwFlags |= MHDR_DONE;
|
||||||
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
|
||||||
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&crit_sect);
|
LeaveCriticalSection(&crit_sect);
|
||||||
|
@ -906,12 +906,11 @@ static DWORD midReset(WORD wDevID)
|
||||||
|
|
||||||
EnterCriticalSection(&crit_sect);
|
EnterCriticalSection(&crit_sect);
|
||||||
while (MidiInDev[wDevID].lpQueueHdr) {
|
while (MidiInDev[wDevID].lpQueueHdr) {
|
||||||
MidiInDev[wDevID].lpQueueHdr->dwFlags &= ~MHDR_INQUEUE;
|
LPMIDIHDR lpMidiHdr = MidiInDev[wDevID].lpQueueHdr;
|
||||||
MidiInDev[wDevID].lpQueueHdr->dwFlags |= MHDR_DONE;
|
MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
|
||||||
/* FIXME: when called from 16 bit, lpQueueHdr needs to be a segmented ptr */
|
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
|
||||||
MIDI_NotifyClient(wDevID, MIM_LONGDATA,
|
lpMidiHdr->dwFlags |= MHDR_DONE;
|
||||||
(DWORD_PTR)MidiInDev[wDevID].lpQueueHdr, dwTime);
|
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime);
|
||||||
MidiInDev[wDevID].lpQueueHdr = MidiInDev[wDevID].lpQueueHdr->lpNext;
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&crit_sect);
|
LeaveCriticalSection(&crit_sect);
|
||||||
|
|
||||||
|
@ -1102,10 +1101,6 @@ static DWORD modOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
|
||||||
WARN("bad dwFlags\n");
|
WARN("bad dwFlags\n");
|
||||||
return MMSYSERR_INVALFLAG;
|
return MMSYSERR_INVALFLAG;
|
||||||
}
|
}
|
||||||
if (!MidiOutDev[wDevID].bEnabled) {
|
|
||||||
TRACE("disabled wDevID\n");
|
|
||||||
return MMSYSERR_NOTENABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
MidiOutDev[wDevID].lpExtra = 0;
|
MidiOutDev[wDevID].lpExtra = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue