mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 06:06:13 +00:00
winealsa: Introduce a notification thread.
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> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3a53573a6a
commit
d40956b7a9
4 changed files with 72 additions and 3 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
return 1;
|
||||
case DRV_FREE:
|
||||
ALSA_CALL(midi_release, NULL);
|
||||
return 1;
|
||||
case DRV_OPEN:
|
||||
case DRV_CLOSE:
|
||||
case DRV_ENABLE:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue