Commit ac1059ff authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Move midi_in_reset to the unixlib.

The headers are removed one at a time so that each notification can be reported back to the client-side. If there are remaining headers, the unixlib will return ERROR_RETRY to request that the client calls again. Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 01ad5030
......@@ -934,6 +934,39 @@ static DWORD midi_in_stop(WORD dev_id)
return MMSYSERR_NOERROR;
}
static DWORD midi_in_reset(WORD dev_id, struct notify_context *notify)
{
DWORD cur_time = NtGetTickCount();
DWORD err = MMSYSERR_NOERROR;
struct midi_src *src;
MIDIHDR *hdr;
TRACE("%d\n", dev_id);
if (dev_id >= num_srcs)
{
WARN("bad device ID : %d\n", dev_id);
return MMSYSERR_BADDEVICEID;
}
src = srcs + dev_id;
midi_in_lock((void *)TRUE);
if (src->lpQueueHdr)
{
hdr = src->lpQueueHdr;
src->lpQueueHdr = hdr->lpNext;
hdr->dwFlags &= ~MHDR_INQUEUE;
hdr->dwFlags |= MHDR_DONE;
set_in_notify(notify, src, dev_id, MIM_LONGDATA, (DWORD_PTR)hdr, cur_time - src->startTime);
if (src->lpQueueHdr) err = ERROR_RETRY; /* ask the client to call again */
}
midi_in_lock((void *)FALSE);
return err;
}
NTSTATUS midi_out_message(void *args)
{
struct midi_out_message_params *params = args;
......@@ -1030,6 +1063,9 @@ NTSTATUS midi_in_message(void *args)
case MIDM_STOP:
*params->err = midi_in_stop(params->dev_id);
break;
case MIDM_RESET:
*params->err = midi_in_reset(params->dev_id, params->notify);
break;
default:
TRACE("Unsupported message\n");
*params->err = MMSYSERR_NOTSUPPORTED;
......
......@@ -142,30 +142,6 @@ static void midi_lock( BOOL lock )
UNIX_CALL(midi_in_lock, (void *)lock);
}
static DWORD MIDIIn_Reset(WORD wDevID)
{
DWORD dwTime = GetTickCount();
TRACE("%d\n", wDevID);
if (wDevID >= MIDIIn_NumDevs) {
WARN("bad device ID : %d\n", wDevID);
return MMSYSERR_BADDEVICEID;
}
midi_lock( TRUE );
while (sources[wDevID].lpQueueHdr) {
LPMIDIHDR lpMidiHdr = sources[wDevID].lpQueueHdr;
sources[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
lpMidiHdr->dwFlags |= MHDR_DONE;
/* FIXME: when called from 16 bit, lpQueueHdr needs to be a segmented ptr */
MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime - sources[wDevID].startTime);
}
midi_lock( FALSE );
return MMSYSERR_NOERROR;
}
/*
* MIDI In Mach message handling
*/
......@@ -335,10 +311,6 @@ DWORD WINAPI CoreAudio_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
DWORD err;
TRACE("%d %08x %08lx %08lx %08lx\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
switch (wMsg) {
case MIDM_RESET:
return MIDIIn_Reset(wDevID);
}
params.dev_id = wDevID;
params.msg = wMsg;
......@@ -348,9 +320,11 @@ DWORD WINAPI CoreAudio_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, DWOR
params.err = &err;
params.notify = &notify;
UNIX_CALL(midi_in_message, &params);
if (!err && notify.send_notify) notify_client(&notify);
do
{
UNIX_CALL(midi_in_message, &params);
if ((!err || err == ERROR_RETRY) && notify.send_notify) notify_client(&notify);
} while (err == ERROR_RETRY);
return err;
}
......
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