From fd43369f1376f246b8ad04e22ad53a6f3b9dc705 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 31 Jul 2011 12:21:11 -0700 Subject: [PATCH] Don't hold the global mutex while destroying the primary buffer Destroying the primary buffer may need to kill a timer, which could be blocked in the middle of running due to the mutex --- dsound8.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/dsound8.c b/dsound8.c index 5bea08d5a0c..8bb1bd6b912 100644 --- a/dsound8.c +++ b/dsound8.c @@ -157,6 +157,7 @@ static void DS8Impl_Destroy(DS8Impl *This) break; } } + LeaveCriticalSection(&openal_crst); if(This->deviceref && InterlockedDecrement(This->deviceref) == 0) { @@ -167,20 +168,24 @@ static void DS8Impl_Destroy(DS8Impl *This) HeapFree(GetProcessHeap(), 0, This->deviceref); } - else if(This->primary && This->primary->parent == This) + else { - /* If the primary is referencing this as its parent, update it to - * reference another handle for the device */ - for(i = 0;i < devicelistsize;i++) + EnterCriticalSection(&openal_crst); + if(This->primary && This->primary->parent == This) { - if(devicelist[i]->primary == This->primary) + /* If the primary is referencing this as its parent, update it to + * reference another handle for the device */ + for(i = 0;i < devicelistsize;i++) { - This->primary->parent = devicelist[i]; - break; + if(devicelist[i]->primary == This->primary) + { + This->primary->parent = devicelist[i]; + break; + } } } + LeaveCriticalSection(&openal_crst); } - LeaveCriticalSection(&openal_crst); HeapFree(GetProcessHeap(), 0, This); } -- 2.11.4.GIT