Huw Davies : winecoreaudio: Move midi_in_reset to the unixlib.
Alexandre Julliard
julliard at winehq.org
Mon Nov 29 16:26:54 CST 2021
Module: wine
Branch: master
Commit: ac1059ff606d1d34817a73ba4951ed4a79fad9a7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ac1059ff606d1d34817a73ba4951ed4a79fad9a7
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Nov 29 11:26:48 2021 +0000
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: Huw Davies <huw at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winecoreaudio.drv/coremidi.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/winecoreaudio.drv/midi.c | 36 +++++-------------------------------
2 files changed, 41 insertions(+), 31 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coremidi.c b/dlls/winecoreaudio.drv/coremidi.c
index 5d89b69e007..9dc9f452c29 100644
--- a/dlls/winecoreaudio.drv/coremidi.c
+++ b/dlls/winecoreaudio.drv/coremidi.c
@@ -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;
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index ab861d44525..dcb9a7e1b69 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -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 = ¬ify;
- UNIX_CALL(midi_in_message, ¶ms);
-
- if (!err && notify.send_notify) notify_client(¬ify);
+ do
+ {
+ UNIX_CALL(midi_in_message, ¶ms);
+ if ((!err || err == ERROR_RETRY) && notify.send_notify) notify_client(¬ify);
+ } while (err == ERROR_RETRY);
return err;
}
More information about the wine-cvs
mailing list