Commit 31c5a82b authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineoss: 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: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 64b96eec
......@@ -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 = &notify;
params.quit = &quit;
while (1)
{
OSS_CALL(midi_notify_wait, &params);
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));
return 1;
case DRV_FREE:
OSS_CALL(midi_release, NULL);
return 1;
case DRV_OPEN:
case DRV_CLOSE:
case DRV_ENABLE:
......
......@@ -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,
......
......@@ -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(&notify_mutex);
if (notify) FIXME("Not yet handled\n");
else notify_quit = TRUE;
pthread_cond_signal(&notify_read_cond);
pthread_mutex_unlock(&notify_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(&notify_mutex);
while (!notify_quit)
pthread_cond_wait(&notify_read_cond, &notify_mutex);
*params->quit = notify_quit;
pthread_mutex_unlock(&notify_mutex);
return STATUS_SUCCESS;
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment