winecoreaudio: Move creation of the audio unit to IAudioClient_Initialize().

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-11-18 07:52:33 +00:00 committed by Alexandre Julliard
parent 7d76fee5f4
commit 3810c693ca
1 changed files with 8 additions and 6 deletions

View File

@ -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);