Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Fri, Apr 29, 2022 at 08:29:53AM +0100, Huw Davies wrote:
Currently the thread just blocks until told to quit by midi_release. Eventually this thread will dispatch the MIM_DATA and MIM_LONGDATA notifications.
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/wineoss.drv/midi.c | 21 ++++++++++++++++++++ dlls/wineoss.drv/oss.c | 2 ++ dlls/wineoss.drv/ossmidi.c | 39 ++++++++++++++++++++++++++++++++++++++ dlls/wineoss.drv/unixlib.h | 10 ++++++++++ 4 files changed, 72 insertions(+)
diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c index e36a737624a..b3f980ab3da 100644 --- a/dlls/wineoss.drv/midi.c +++ b/dlls/wineoss.drv/midi.c @@ -552,6 +552,23 @@ DWORD WINAPI OSS_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, return err; }
+static DWORD WINAPI notify_thread(void *p) +{
- struct midi_notify_wait_params params;
- struct notify_context notify;
- BOOL quit;
- params.notify = ¬ify;
- params.quit = &quit;
- while (1)
- {
OSS_CALL(midi_notify_wait, ¶ms);
if (quit) break;
- }
- return 0;
+}
/**************************************************************************
DriverProc (WINEOSS.1)
*/ @@ -563,7 +580,11 @@ LRESULT CALLBACK OSS_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
switch(wMsg) { case DRV_LOAD:
CloseHandle(CreateThread(NULL, 0, notify_thread, NULL, 0, NULL));
case DRV_FREE:return 1;
OSS_CALL(midi_release, NULL);
case DRV_OPEN: case DRV_CLOSE: case DRV_ENABLE:return 1;
diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index a9081f2cac9..8fda9270a4e 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -1406,8 +1406,10 @@ unixlib_entry_t __wine_unix_call_funcs[] = set_event_handle, is_started, midi_init,
midi_release, midi_out_message, midi_in_message,
midi_notify_wait,
midi_seq_open, midi_in_lock,
diff --git a/dlls/wineoss.drv/ossmidi.c b/dlls/wineoss.drv/ossmidi.c index 86d766eceaf..0790eaaec1a 100644 --- a/dlls/wineoss.drv/ossmidi.c +++ b/dlls/wineoss.drv/ossmidi.c @@ -66,6 +66,10 @@ static unsigned int num_dests, num_srcs, num_synths, seq_refs; static struct midi_dest dests[MAX_MIDIOUTDRV]; static struct midi_src srcs[MAX_MIDIINDRV];
+static pthread_mutex_t notify_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t notify_read_cond = PTHREAD_COND_INITIALIZER; +static BOOL notify_quit;
typedef struct sVoice { int note; /* 0 means not used */ @@ -155,6 +159,17 @@ NTSTATUS midi_in_lock(void *args) return STATUS_SUCCESS; }
+static void notify_post(struct notify_context *notify) +{
- pthread_mutex_lock(¬ify_mutex);
- if (notify) FIXME("Not yet handled\n");
- else notify_quit = TRUE;
- pthread_cond_signal(¬ify_read_cond);
- pthread_mutex_unlock(¬ify_mutex);
+}
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) { @@ -432,6 +447,14 @@ wrapup: return STATUS_SUCCESS; }
+NTSTATUS midi_release(void *args) +{
- /* stop the notify_wait thread */
- notify_post(NULL);
- return STATUS_SUCCESS;
+}
/* FIXME: this is a bad idea, it's even not static... */ SEQ_DEFINEBUF(1024);
@@ -1367,3 +1390,19 @@ NTSTATUS midi_in_message(void *args)
return STATUS_SUCCESS;
}
+NTSTATUS midi_notify_wait(void *args) +{
- struct midi_notify_wait_params *params = args;
- pthread_mutex_lock(¬ify_mutex);
- while (!notify_quit)
pthread_cond_wait(¬ify_read_cond, ¬ify_mutex);
- *params->quit = notify_quit;
- pthread_mutex_unlock(¬ify_mutex);
- return STATUS_SUCCESS;
+} diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index 867e1ff656e..ddeba49556c 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -267,6 +267,12 @@ struct midi_in_message_params struct notify_context *notify; };
+struct midi_notify_wait_params +{
- BOOL *quit;
- struct notify_context *notify;
+};
struct midi_seq_open_params { int close; @@ -299,16 +305,20 @@ enum oss_funcs oss_set_event_handle, oss_is_started, oss_midi_init,
oss_midi_release, oss_midi_out_message, oss_midi_in_message,
oss_midi_notify_wait,
oss_midi_seq_open, /* temporary */ oss_midi_in_lock,
};
NTSTATUS midi_init(void *args) DECLSPEC_HIDDEN; +NTSTATUS midi_release(void *args) DECLSPEC_HIDDEN; NTSTATUS midi_out_message(void *args) DECLSPEC_HIDDEN; NTSTATUS midi_in_message(void *args) DECLSPEC_HIDDEN; +NTSTATUS midi_notify_wait(void *args) DECLSPEC_HIDDEN; NTSTATUS midi_seq_open(void *args) DECLSPEC_HIDDEN; NTSTATUS midi_in_lock(void *args) DECLSPEC_HIDDEN;
-- 2.25.1