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

mmdevapi: IsFormatSupported fills closest match iff it returns S_FALSE.

parent 03d4ef95
......@@ -1189,6 +1189,9 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface,
dump_fmt(fmt);
if(out)
*out = NULL;
EnterCriticalSection(&This->lock);
if((err = snd_pcm_hw_params_any(This->pcm_handle, This->hw_params)) < 0){
......@@ -1320,17 +1323,14 @@ exit:
LeaveCriticalSection(&This->lock);
HeapFree(GetProcessHeap(), 0, formats);
if(hr == S_OK || !out){
CoTaskMemFree(closest);
if(out)
*out = NULL;
}else if(closest){
if(hr == S_FALSE && out) {
closest->nBlockAlign =
closest->nChannels * closest->wBitsPerSample / 8;
closest->nAvgBytesPerSec =
closest->nBlockAlign * closest->nSamplesPerSec;
*out = closest;
}
} else
CoTaskMemFree(closest);
TRACE("returning: %08x\n", hr);
return hr;
......
......@@ -676,6 +676,9 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
WAVEFORMATEXTENSIBLE *fmtex = (void*)fmt;
WAVEFORMATEX *closest = NULL;
if(out)
*out = NULL;
tmp = oss_format = get_oss_format(fmt);
if(oss_format < 0)
return AUDCLNT_E_UNSUPPORTED_FORMAT;
......@@ -689,6 +692,8 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
}
closest = clone_format(fmt);
if(!closest)
return E_OUTOFMEMORY;
tmp = fmt->nSamplesPerSec;
if(ioctl(This->fd, SNDCTL_DSP_SPEED, &tmp) < 0){
......@@ -723,17 +728,14 @@ static HRESULT setup_oss_device(ACImpl *This, const WAVEFORMATEX *fmt,
ret = S_FALSE;
}
if(ret == S_OK || !out){
CoTaskMemFree( closest);
if(out)
*out = NULL;
}else{
if(ret == S_FALSE && out){
closest->nBlockAlign =
closest->nChannels * closest->wBitsPerSample / 8;
closest->nAvgBytesPerSec =
closest->nBlockAlign * closest->nSamplesPerSec;
*out = closest;
}
} else
CoTaskMemFree(closest);
TRACE("returning: %08x\n", ret);
return ret;
......
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