Commit 0aea30e4 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

dsound: Do not wait on mixer thread exit on dsound release.

This fixes a loader deadlock if the dsound object is being released during a dll unload.
parent 0221688c
...@@ -208,8 +208,9 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device) ...@@ -208,8 +208,9 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
SetEvent(device->sleepev); SetEvent(device->sleepev);
if (device->thread) { if (device->thread) {
WaitForSingleObject(device->thread, INFINITE); WaitForSingleObject(device->thread_finished, INFINITE);
CloseHandle(device->thread); CloseHandle(device->thread);
CloseHandle(device->thread_finished);
} }
CloseHandle(device->sleepev); CloseHandle(device->sleepev);
...@@ -384,6 +385,7 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU ...@@ -384,6 +385,7 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU
hr = DSOUND_PrimaryCreate(device); hr = DSOUND_PrimaryCreate(device);
if (hr == DS_OK) { if (hr == DS_OK) {
device->thread_finished = CreateEventW(0, 0, 0, 0);
device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0); device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0);
SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL); SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
} else } else
......
...@@ -108,6 +108,7 @@ struct DirectSoundDevice ...@@ -108,6 +108,7 @@ struct DirectSoundDevice
IAudioRenderClient *render; IAudioRenderClient *render;
HANDLE sleepev, thread; HANDLE sleepev, thread;
HANDLE thread_finished;
struct list entry; struct list entry;
}; };
......
...@@ -909,5 +909,6 @@ DWORD CALLBACK DSOUND_mixthread(void *p) ...@@ -909,5 +909,6 @@ DWORD CALLBACK DSOUND_mixthread(void *p)
DSOUND_PerformMix(dev); DSOUND_PerformMix(dev);
RtlReleaseResource(&(dev->buffer_list_lock)); RtlReleaseResource(&(dev->buffer_list_lock));
} }
SetEvent(dev->thread_finished);
return 0; return 0;
} }
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