Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Mon, Nov 29, 2021 at 11:26:46AM +0000, Huw Davies wrote:
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/winecoreaudio.drv/coremidi.c | 46 ++++++++++++++++++++++++++++ dlls/winecoreaudio.drv/midi.c | 50 ------------------------------- 2 files changed, 46 insertions(+), 50 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c index 8e12ad1a3c5..5d89b69e007 100644 --- a/dlls/winecoreaudio.drv/coremidi.c +++ b/dlls/winecoreaudio.drv/coremidi.c @@ -809,6 +809,49 @@ static DWORD midi_in_close(WORD dev_id, struct notify_context *notify) return MMSYSERR_NOERROR; }
+static DWORD midi_in_add_buffer(WORD dev_id, MIDIHDR *hdr, DWORD hdr_size) +{
- MIDIHDR **next;
- TRACE("dev_id = %d hdr = %p hdr_size = %d\n", dev_id, hdr, hdr_size);
- if (dev_id >= num_srcs)
- {
WARN("bad device ID : %d\n", dev_id);
return MMSYSERR_BADDEVICEID;
- }
- if (!hdr || hdr_size < offsetof(MIDIHDR, dwOffset) || !hdr->dwBufferLength)
- {
WARN("Invalid Parameter\n");
return MMSYSERR_INVALPARAM;
- }
- if (hdr->dwFlags & MHDR_INQUEUE)
- {
WARN("Still playing\n");
return MIDIERR_STILLPLAYING;
- }
- if (!(hdr->dwFlags & MHDR_PREPARED))
- {
WARN("Unprepared\n");
return MIDIERR_UNPREPARED;
- }
- hdr->dwFlags &= ~WHDR_DONE;
- hdr->dwFlags |= MHDR_INQUEUE;
- hdr->dwBytesRecorded = 0;
- hdr->lpNext = NULL;
- midi_in_lock((void *)TRUE);
- next = &srcs[dev_id].lpQueueHdr;
- while (*next) next = &(*next)->lpNext;
- *next = hdr;
- midi_in_lock((void *)FALSE);
- return MMSYSERR_NOERROR;
+}
static DWORD midi_in_prepare(WORD dev_id, MIDIHDR *hdr, DWORD hdr_size) { TRACE("dev_id = %d hdr = %p hdr_size = %d\n", dev_id, hdr, hdr_size); @@ -966,6 +1009,9 @@ NTSTATUS midi_in_message(void *args) case MIDM_CLOSE: *params->err = midi_in_close(params->dev_id, params->notify); break;
- case MIDM_ADDBUFFER:
*params->err = midi_in_add_buffer(params->dev_id, (MIDIHDR *)params->param_1, params->param_2);
case MIDM_PREPARE: *params->err = midi_in_prepare(params->dev_id, (MIDIHDR *)params->param_1, params->param_2); break;break;
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c index 7894b4da906..4eb68c8b1d7 100644 --- a/dlls/winecoreaudio.drv/midi.c +++ b/dlls/winecoreaudio.drv/midi.c @@ -142,54 +142,6 @@ static void midi_lock( BOOL lock ) UNIX_CALL(midi_in_lock, (void *)lock); }
-static DWORD MIDIIn_AddBuffer(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) -{
- TRACE("wDevID=%d lpMidiHdr=%p dwSize=%d\n", wDevID, lpMidiHdr, dwSize);
- if (wDevID >= MIDIIn_NumDevs) {
WARN("bad device ID : %d\n", wDevID);
- return MMSYSERR_BADDEVICEID;
- }
- if (lpMidiHdr == NULL) {
- WARN("Invalid Parameter\n");
- return MMSYSERR_INVALPARAM;
- }
- if (dwSize < offsetof(MIDIHDR,dwOffset)) {
- WARN("Invalid Parameter\n");
- return MMSYSERR_INVALPARAM;
- }
- if (lpMidiHdr->dwBufferLength == 0) {
- WARN("Invalid Parameter\n");
- return MMSYSERR_INVALPARAM;
- }
- if (lpMidiHdr->dwFlags & MHDR_INQUEUE) {
- WARN("Still playing\n");
- return MIDIERR_STILLPLAYING;
- }
- if (!(lpMidiHdr->dwFlags & MHDR_PREPARED)) {
- WARN("Unprepared\n");
- return MIDIERR_UNPREPARED;
- }
- midi_lock( TRUE );
- lpMidiHdr->dwFlags &= ~WHDR_DONE;
- lpMidiHdr->dwFlags |= MHDR_INQUEUE;
- lpMidiHdr->dwBytesRecorded = 0;
- lpMidiHdr->lpNext = 0;
- if (sources[wDevID].lpQueueHdr == 0) {
- sources[wDevID].lpQueueHdr = lpMidiHdr;
- } else {
- LPMIDIHDR ptr;
- for (ptr = sources[wDevID].lpQueueHdr;
ptr->lpNext != 0;
ptr = ptr->lpNext);
- ptr->lpNext = lpMidiHdr;
- }
- midi_lock( FALSE );
- return MMSYSERR_NOERROR;
-}
static DWORD MIDIIn_Reset(WORD wDevID) { DWORD dwTime = GetTickCount(); @@ -384,8 +336,6 @@ DWORD WINAPI CoreAudio_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2); switch (wMsg) {
case MIDM_ADDBUFFER:
}return MIDIIn_AddBuffer(wDevID, (LPMIDIHDR)dwParam1, dwParam2); case MIDM_RESET: return MIDIIn_Reset(wDevID);
-- 2.23.0