winealsa: Don't acquire the sessions lock after the client lock.

This could lead to a deadlock with AudioSessionControl_GetState()
which acquires the locks in the other order.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-12-02 12:02:38 +00:00 committed by Alexandre Julliard
parent 8e0b337df1
commit 1acba9d959

View file

@ -1344,10 +1344,12 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
}
}
EnterCriticalSection(&g_sessions_lock);
EnterCriticalSection(&This->lock);
if(This->initted){
LeaveCriticalSection(&This->lock);
LeaveCriticalSection(&g_sessions_lock);
return AUDCLNT_E_ALREADY_INITIALIZED;
}
@ -1537,19 +1539,13 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
This->share = mode;
This->flags = flags;
EnterCriticalSection(&g_sessions_lock);
hr = get_audio_session(sessionguid, This->parent, fmt->nChannels,
&This->session);
if(FAILED(hr)){
LeaveCriticalSection(&g_sessions_lock);
if(FAILED(hr))
goto exit;
}
list_add_tail(&This->session->clients, &This->entry);
LeaveCriticalSection(&g_sessions_lock);
This->initted = TRUE;
TRACE("ALSA period: %lu frames\n", This->alsa_period_frames);
@ -1569,6 +1565,7 @@ exit:
}
LeaveCriticalSection(&This->lock);
LeaveCriticalSection(&g_sessions_lock);
return hr;
}