winecoreaudio: Properly allocate the WAVEFORMATEXTENSIBLE returned by GetMixFormat.

This commit is contained in:
Jörg Höhle 2011-06-05 10:26:57 +02:00 committed by Alexandre Julliard
parent d726cf8819
commit 8337ffb727
1 changed files with 8 additions and 8 deletions

View File

@ -1155,13 +1155,12 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
if(!pwfx) if(!pwfx)
return E_POINTER; return E_POINTER;
*pwfx = NULL;
*pwfx = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEXTENSIBLE)); fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE));
if(!*pwfx) if(!fmt)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
fmt = (WAVEFORMATEXTENSIBLE*)*pwfx;
fmt->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; fmt->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
addr.mScope = This->scope; addr.mScope = This->scope;
@ -1170,21 +1169,21 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
sc = AudioObjectGetPropertyDataSize(This->adevid, &addr, 0, NULL, &size); sc = AudioObjectGetPropertyDataSize(This->adevid, &addr, 0, NULL, &size);
if(sc != noErr){ if(sc != noErr){
HeapFree(GetProcessHeap(), 0, fmt); CoTaskMemFree(fmt);
WARN("Unable to get size for _StreamConfiguration property: %lx\n", sc); WARN("Unable to get size for _StreamConfiguration property: %lx\n", sc);
return E_FAIL; return E_FAIL;
} }
buffers = HeapAlloc(GetProcessHeap(), 0, size); buffers = HeapAlloc(GetProcessHeap(), 0, size);
if(!buffers){ if(!buffers){
HeapFree(GetProcessHeap(), 0, fmt); CoTaskMemFree(fmt);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL,
&size, buffers); &size, buffers);
if(sc != noErr){ if(sc != noErr){
HeapFree(GetProcessHeap(), 0, fmt); CoTaskMemFree(fmt);
HeapFree(GetProcessHeap(), 0, buffers); HeapFree(GetProcessHeap(), 0, buffers);
WARN("Unable to get _StreamConfiguration property: %lx\n", sc); WARN("Unable to get _StreamConfiguration property: %lx\n", sc);
return E_FAIL; return E_FAIL;
@ -1202,7 +1201,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
size = sizeof(Float64); size = sizeof(Float64);
sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, &size, &rate); sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, &size, &rate);
if(sc != noErr){ if(sc != noErr){
HeapFree(GetProcessHeap(), 0, fmt); CoTaskMemFree(fmt);
WARN("Unable to get _NominalSampleRate property: %lx\n", sc); WARN("Unable to get _NominalSampleRate property: %lx\n", sc);
return E_FAIL; return E_FAIL;
} }
@ -1221,6 +1220,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
fmt->Samples.wValidBitsPerSample = fmt->Format.wBitsPerSample; fmt->Samples.wValidBitsPerSample = fmt->Format.wBitsPerSample;
fmt->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); fmt->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
*pwfx = (WAVEFORMATEX*)fmt;
dump_fmt(*pwfx); dump_fmt(*pwfx);
return S_OK; return S_OK;