Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, Mar 23, 2022 at 08:16:53AM +0000, 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/winealsa.drv/alsa.c | 2 ++ dlls/winealsa.drv/alsamidi.c | 39 ++++++++++++++++++++++++++++++++++++ dlls/winealsa.drv/midi.c | 24 +++++++++++++++++++--- dlls/winealsa.drv/unixlib.h | 10 +++++++++ 4 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c index eb16203dbf9..5b592986c06 100644 --- a/dlls/winealsa.drv/alsa.c +++ b/dlls/winealsa.drv/alsa.c @@ -2445,8 +2445,10 @@ unixlib_entry_t __wine_unix_call_funcs[] = is_started, get_prop_value, midi_init,
midi_release, midi_out_message, midi_in_message,
midi_notify_wait,
midi_seq_lock, /* temporary */ midi_in_lock,
diff --git a/dlls/winealsa.drv/alsamidi.c b/dlls/winealsa.drv/alsamidi.c index ccdb35731d1..e10779f63a1 100644 --- a/dlls/winealsa.drv/alsamidi.c +++ b/dlls/winealsa.drv/alsamidi.c @@ -69,6 +69,10 @@ static snd_seq_t *midi_seq; static unsigned int seq_refs; static int port_in = -1;
+static pthread_mutex_t notify_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t notify_cond = PTHREAD_COND_INITIALIZER; +static BOOL notify_quit;
static void seq_lock(void) { pthread_mutex_lock(&seq_mutex); @@ -119,6 +123,17 @@ static void set_in_notify(struct notify_context *notify, struct midi_src *src, W notify->instance = src->midiDesc.dwInstance; }
+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_cond);
- pthread_mutex_unlock(¬ify_mutex);
+}
static snd_seq_t *seq_open(int *port_in_ret) { static int midi_warn; @@ -405,6 +420,14 @@ NTSTATUS midi_init(void *args) return STATUS_SUCCESS; }
+NTSTATUS midi_release(void *args) +{
- /* stop the notify_wait thread */
- notify_post(NULL);
- return STATUS_SUCCESS;
+}
static void set_out_notify(struct notify_context *notify, struct midi_dest *dest, WORD dev_id, WORD msg, UINT_PTR param_1, UINT_PTR param_2) { @@ -1101,3 +1124,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_cond, ¬ify_mutex);
- *params->quit = notify_quit;
- pthread_mutex_unlock(¬ify_mutex);
- return STATUS_SUCCESS;
+} diff --git a/dlls/winealsa.drv/midi.c b/dlls/winealsa.drv/midi.c index 35678588549..ca31def8d16 100644 --- a/dlls/winealsa.drv/midi.c +++ b/dlls/winealsa.drv/midi.c @@ -557,18 +557,36 @@ DWORD WINAPI ALSA_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)
- {
ALSA_CALL(midi_notify_wait, ¶ms);
if (quit) break;
- }
- return 0;
+}
/**************************************************************************
DriverProc (WINEALSA.@)
*/ LRESULT CALLBACK ALSA_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, LPARAM dwParam1, LPARAM dwParam2) { -/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */ -/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
- switch(wMsg) { case DRV_LOAD:
CloseHandle(CreateThread(NULL, 0, notify_thread, NULL, 0, NULL));
case DRV_FREE:return 1;
ALSA_CALL(midi_release, NULL);
case DRV_OPEN: case DRV_CLOSE: case DRV_ENABLE:return 1;
diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h index 6d5bcb64cf0..68ab650d2f6 100644 --- a/dlls/winealsa.drv/unixlib.h +++ b/dlls/winealsa.drv/unixlib.h @@ -265,6 +265,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; @@ -298,8 +304,10 @@ enum alsa_funcs alsa_is_started, alsa_get_prop_value, alsa_midi_init,
alsa_midi_release, alsa_midi_out_message, alsa_midi_in_message,
alsa_midi_notify_wait,
alsa_midi_seq_lock, /* temporary */ alsa_midi_in_lock,
@@ -307,8 +315,10 @@ enum alsa_funcs };
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_lock(void *args) DECLSPEC_HIDDEN; NTSTATUS midi_in_lock(void *args) DECLSPEC_HIDDEN; -- 2.25.1