Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/wineoss.drv/midi.c | 35 ++++++---------------------
dlls/wineoss.drv/ossmidi.c | 49 ++++++++++++++++++++++++++++++++++++++
dlls/wineoss.drv/unixlib.h | 1 +
3 files changed, 57 insertions(+), 28 deletions(-)
diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c
index 44491a98cfa..8d4c9bab68c 100644
--- a/dlls/wineoss.drv/midi.c
+++ b/dlls/wineoss.drv/midi.c
@@ -490,31 +490,6 @@ static DWORD midClose(WORD wDevID)
return ret;
}
-/**************************************************************************
- * midReset [internal]
- */
-static DWORD midReset(WORD wDevID)
-{
- DWORD dwTime = GetTickCount();
-
- TRACE("(%04X);\n", wDevID);
-
- if (wDevID >= MIDM_NumDevs) return MMSYSERR_BADDEVICEID;
- if (MidiInDev[wDevID].state == -1) return MIDIERR_NODEVICE;
-
- in_buffer_lock();
- while (MidiInDev[wDevID].lpQueueHdr) {
- LPMIDIHDR lpMidiHdr = MidiInDev[wDevID].lpQueueHdr;
- MidiInDev[wDevID].lpQueueHdr = lpMidiHdr->lpNext;
- lpMidiHdr->dwFlags &= ~MHDR_INQUEUE;
- lpMidiHdr->dwFlags |= MHDR_DONE;
- MIDI_NotifyClient(wDevID, MIM_LONGDATA, (DWORD_PTR)lpMidiHdr, dwTime - MidiInDev[wDevID].startTime);
- }
- in_buffer_unlock();
-
- return MMSYSERR_NOERROR;
-}
-
/**************************************************************************
* midStart [internal]
*/
@@ -555,6 +530,7 @@ DWORD WINAPI OSS_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
struct midi_in_message_params params;
+ struct notify_context notify;
UINT err;
TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
@@ -568,8 +544,6 @@ DWORD WINAPI OSS_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return midOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2);
case MIDM_CLOSE:
return midClose(wDevID);
- case MIDM_RESET:
- return midReset(wDevID);
case MIDM_START:
return midStart(wDevID);
case MIDM_STOP:
@@ -582,8 +556,13 @@ DWORD WINAPI OSS_midMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
params.param_1 = dwParam1;
params.param_2 = dwParam2;
params.err = &err;
+ params.notify = ¬ify;
- OSS_CALL(midi_in_message, ¶ms);
+ do
+ {
+ OSS_CALL(midi_in_message, ¶ms);
+ if ((!err || err == ERROR_RETRY) && notify.send_notify) notify_client(¬ify);
+ } while (err == ERROR_RETRY);
return err;
}
diff --git a/dlls/wineoss.drv/ossmidi.c b/dlls/wineoss.drv/ossmidi.c
index 8fca6e32c41..d63ba936239 100644
--- a/dlls/wineoss.drv/ossmidi.c
+++ b/dlls/wineoss.drv/ossmidi.c
@@ -155,6 +155,20 @@ NTSTATUS midi_in_lock(void *args)
return STATUS_SUCCESS;
}
+static void set_in_notify(struct notify_context *notify, struct midi_src *src, WORD dev_id, WORD msg,
+ UINT_PTR param_1, UINT_PTR param_2)
+{
+ notify->send_notify = TRUE;
+ notify->dev_id = dev_id;
+ notify->msg = msg;
+ notify->param_1 = param_1;
+ notify->param_2 = param_2;
+ notify->callback = src->midiDesc.dwCallback;
+ notify->flags = src->wFlags;
+ notify->device = src->midiDesc.hMidi;
+ notify->instance = src->midiDesc.dwInstance;
+}
+
static int seq_open(void)
{
static int midi_warn = 1;
@@ -1196,6 +1210,36 @@ static UINT midi_in_get_devcaps(WORD dev_id, MIDIINCAPSW *caps, UINT size)
return MMSYSERR_NOERROR;
}
+static UINT midi_in_reset(WORD dev_id, struct notify_context *notify)
+{
+ UINT cur_time = NtGetTickCount();
+ UINT err = MMSYSERR_NOERROR;
+ struct midi_src *src;
+ MIDIHDR *hdr;
+
+ TRACE("(%04X);\n", dev_id);
+
+ if (dev_id >= num_srcs) return MMSYSERR_BADDEVICEID;
+ src = srcs + dev_id;
+ if (src->state == -1) return MIDIERR_NODEVICE;
+
+ in_buffer_lock();
+
+ 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, (UINT_PTR)hdr, cur_time - src->startTime);
+ if (src->lpQueueHdr) err = ERROR_RETRY; /* ask the client to call again */
+ }
+
+ in_buffer_unlock();
+
+ return err;
+}
+
NTSTATUS midi_out_message(void *args)
{
struct midi_out_message_params *params = args;
@@ -1254,6 +1298,8 @@ NTSTATUS midi_in_message(void *args)
{
struct midi_in_message_params *params = args;
+ params->notify->send_notify = FALSE;
+
switch (params->msg)
{
case DRVM_ENABLE:
@@ -1276,6 +1322,9 @@ NTSTATUS midi_in_message(void *args)
case MIDM_GETNUMDEVS:
*params->err = num_srcs;
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/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h
index 544a462dcc4..867e1ff656e 100644
--- a/dlls/wineoss.drv/unixlib.h
+++ b/dlls/wineoss.drv/unixlib.h
@@ -264,6 +264,7 @@ struct midi_in_message_params
UINT_PTR param_1;
UINT_PTR param_2;
UINT *err;
+ struct notify_context *notify;
};
struct midi_seq_open_params
--
2.25.1