Commit c9950119 authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

winecoreaudio: Avoid deadlock in AudioClient_Stop.

parent 051cb8e6
...@@ -1440,8 +1440,12 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface) ...@@ -1440,8 +1440,12 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
if(This->event) if(This->event)
if(!CreateTimerQueueTimer(&This->timer, g_timer_q, if(!CreateTimerQueueTimer(&This->timer, g_timer_q,
ca_period_cb, This, 0, This->period_ms, 0)) ca_period_cb, This, 0, This->period_ms, 0)){
ERR("Unable to create timer: %u\n", GetLastError()); This->timer = NULL;
OSSpinLockUnlock(&This->lock);
WARN("Unable to create timer: %u\n", GetLastError());
return E_OUTOFMEMORY;
}
This->playing = StateInTransition; This->playing = StateInTransition;
...@@ -1467,6 +1471,8 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface) ...@@ -1467,6 +1471,8 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
ACImpl *This = impl_from_IAudioClient(iface); ACImpl *This = impl_from_IAudioClient(iface);
AudioTimeStamp tstamp; AudioTimeStamp tstamp;
OSStatus sc; OSStatus sc;
HANDLE event = NULL;
BOOL wait = FALSE;
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
...@@ -1487,9 +1493,13 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface) ...@@ -1487,9 +1493,13 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
return S_OK; return S_OK;
} }
if(This->timer && This->timer != INVALID_HANDLE_VALUE){ if(This->timer){
DeleteTimerQueueTimer(g_timer_q, This->timer, INVALID_HANDLE_VALUE); event = CreateEventW(NULL, TRUE, FALSE, NULL);
wait = !DeleteTimerQueueTimer(g_timer_q, This->timer, event);
This->timer = NULL; This->timer = NULL;
if(wait)
WARN("DeleteTimerQueueTimer error %u\n", GetLastError());
wait = wait && GetLastError() == ERROR_IO_PENDING;
} }
This->playing = StateInTransition; This->playing = StateInTransition;
...@@ -1506,6 +1516,10 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface) ...@@ -1506,6 +1516,10 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
OSSpinLockUnlock(&This->lock); OSSpinLockUnlock(&This->lock);
if(event && wait)
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
sc = AudioQueueFlush(This->aqueue); sc = AudioQueueFlush(This->aqueue);
if(sc != noErr) if(sc != noErr)
WARN("Unable to flush audio queue: %lx\n", sc); WARN("Unable to flush audio queue: %lx\n", sc);
......
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