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