Commit b4c7823b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winepulse: Use event handle to signal main loop readiness.

parent 73c08fb6
......@@ -193,8 +193,9 @@ static inline ACImpl *impl_from_IAudioStreamVolume(IAudioStreamVolume *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioStreamVolume_iface);
}
static DWORD CALLBACK pulse_mainloop_thread(void *tmp) {
pulse->main_loop();
static DWORD CALLBACK pulse_mainloop_thread(void *event)
{
pulse->main_loop(event);
return 0;
}
......@@ -557,14 +558,17 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
if (!pulse_thread)
{
if (!(pulse_thread = CreateThread(NULL, 0, pulse_mainloop_thread, NULL, 0, NULL)))
HANDLE event = CreateEventW(NULL, TRUE, FALSE, NULL);
if (!(pulse_thread = CreateThread(NULL, 0, pulse_mainloop_thread, event, 0, NULL)))
{
ERR("Failed to create mainloop thread.\n");
pulse->unlock();
CloseHandle(event);
return E_FAIL;
}
SetThreadPriority(pulse_thread, THREAD_PRIORITY_TIME_CRITICAL);
pulse->cond_wait();
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
}
name = get_application_name();
......
......@@ -109,7 +109,7 @@ static void WINAPI pulse_unlock(void)
pthread_mutex_unlock(&pulse_mutex);
}
static int WINAPI pulse_cond_wait(void)
static int pulse_cond_wait(void)
{
return pthread_cond_wait(&pulse_cond, &pulse_mutex);
}
......@@ -175,13 +175,13 @@ static int pulse_poll_func(struct pollfd *ufds, unsigned long nfds, int timeout,
return r;
}
static void WINAPI pulse_main_loop(void)
static void WINAPI pulse_main_loop(HANDLE event)
{
int ret;
pulse_ml = pa_mainloop_new();
pa_mainloop_set_poll_func(pulse_ml, pulse_poll_func, NULL);
NtSetEvent(event, NULL);
pulse_lock();
pulse_broadcast();
pa_mainloop_run(pulse_ml, &ret);
pulse_unlock();
pa_mainloop_free(pulse_ml);
......@@ -1809,7 +1809,6 @@ static const struct unix_funcs unix_funcs =
{
pulse_lock,
pulse_unlock,
pulse_cond_wait,
pulse_main_loop,
pulse_create_stream,
pulse_release_stream,
......
......@@ -35,8 +35,7 @@ struct unix_funcs
{
void (WINAPI *lock)(void);
void (WINAPI *unlock)(void);
int (WINAPI *cond_wait)(void);
void (WINAPI *main_loop)(void);
void (WINAPI *main_loop)(HANDLE event);
HRESULT (WINAPI *create_stream)(const char *name, EDataFlow dataflow, AUDCLNT_SHAREMODE mode,
DWORD flags, REFERENCE_TIME duration, REFERENCE_TIME period,
const WAVEFORMATEX *fmt, UINT32 *channel_count,
......
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