From 3810c693cacf7a8b763d32505a49bf70b151d169 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 18 Nov 2021 07:52:33 +0000 Subject: [PATCH] winecoreaudio: Move creation of the audio unit to IAudioClient_Initialize(). Signed-off-by: Huw Davies Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winecoreaudio.drv/mmdevdrv.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 642610b4b60..56f533f8bc1 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -580,12 +580,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient This->adevid = adevid; - if(!(This->stream->unit = get_audiounit(This->dataflow, This->adevid))){ - HeapFree(GetProcessHeap(), 0, This->stream); - HeapFree(GetProcessHeap(), 0, This); - return AUDCLNT_E_DEVICE_INVALIDATED; - } - *out = (IAudioClient *)&This->IAudioClient3_iface; IAudioClient3_AddRef(&This->IAudioClient3_iface); @@ -1262,6 +1256,14 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE) This->stream->bufsize_frames -= This->stream->bufsize_frames % This->stream->period_frames; + if(!(This->stream->unit = get_audiounit(This->dataflow, This->adevid))){ + CoTaskMemFree(This->stream->fmt); + This->stream->fmt = NULL; + OSSpinLockUnlock(&This->stream->lock); + LeaveCriticalSection(&g_sessions_lock); + return AUDCLNT_E_DEVICE_INVALIDATED; + } + hr = ca_setup_audiounit(This->dataflow, This->stream->unit, This->stream->fmt, &This->stream->dev_desc, &This->stream->converter); if(FAILED(hr)){ CoTaskMemFree(This->stream->fmt);