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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 18 10:26:28 CDT 2015


Module: wine
Branch: master
Commit: 0aea30e44cad38e63d541df1ef2478dd6534f388
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0aea30e44cad38e63d541df1ef2478dd6534f388

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Mar 17 11:35:47 2015 -0500

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.

---

 dlls/dsound/dsound.c         | 4 +++-
 dlls/dsound/dsound_private.h | 1 +
 dlls/dsound/mixer.c          | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index 824f581..065c377 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -208,8 +208,9 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
 
         SetEvent(device->sleepev);
         if (device->thread) {
-            WaitForSingleObject(device->thread, INFINITE);
+            WaitForSingleObject(device->thread_finished, INFINITE);
             CloseHandle(device->thread);
+            CloseHandle(device->thread_finished);
         }
         CloseHandle(device->sleepev);
 
@@ -384,6 +385,7 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU
 
     hr = DSOUND_PrimaryCreate(device);
     if (hr == DS_OK) {
+        device->thread_finished = CreateEventW(0, 0, 0, 0);
         device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0);
         SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
     } else
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 9c58679..9c001ed 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -108,6 +108,7 @@ struct DirectSoundDevice
     IAudioRenderClient *render;
 
     HANDLE sleepev, thread;
+    HANDLE thread_finished;
     struct list entry;
 };
 
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index 8dbd15a..85ab14a 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -909,5 +909,6 @@ DWORD CALLBACK DSOUND_mixthread(void *p)
 		DSOUND_PerformMix(dev);
 		RtlReleaseResource(&(dev->buffer_list_lock));
 	}
+	SetEvent(dev->thread_finished);
 	return 0;
 }




More information about the wine-cvs mailing list