Commit 75b57ea1 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Move is_format_supported to the unixlib.

parent 95931fcd
......@@ -948,10 +948,75 @@ static NTSTATUS get_mix_format(void *args)
return STATUS_SUCCESS;
}
static NTSTATUS is_format_supported(void *args)
{
struct is_format_supported_params *params = args;
const WAVEFORMATEXTENSIBLE *fmtex = (const WAVEFORMATEXTENSIBLE *)params->fmt_in;
AudioStreamBasicDescription dev_desc;
AudioConverterRef converter;
AudioComponentInstance unit;
params->result = S_OK;
if(!params->fmt_in || (params->share == AUDCLNT_SHAREMODE_SHARED && !params->fmt_out))
params->result = E_POINTER;
else if(params->share != AUDCLNT_SHAREMODE_SHARED && params->share != AUDCLNT_SHAREMODE_EXCLUSIVE)
params->result = E_INVALIDARG;
else if(params->fmt_in->wFormatTag == WAVE_FORMAT_EXTENSIBLE){
if(params->fmt_in->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
params->result = E_INVALIDARG;
else if(params->fmt_in->nAvgBytesPerSec == 0 || params->fmt_in->nBlockAlign == 0 ||
fmtex->Samples.wValidBitsPerSample > params->fmt_in->wBitsPerSample)
params->result = E_INVALIDARG;
else if(fmtex->Samples.wValidBitsPerSample < params->fmt_in->wBitsPerSample)
goto unsupported;
else if(params->share == AUDCLNT_SHAREMODE_EXCLUSIVE &&
(fmtex->dwChannelMask == 0 || fmtex->dwChannelMask & SPEAKER_RESERVED))
goto unsupported;
}
if(FAILED(params->result)) return STATUS_SUCCESS;
if(params->fmt_in->nBlockAlign != params->fmt_in->nChannels * params->fmt_in->wBitsPerSample / 8 ||
params->fmt_in->nAvgBytesPerSec != params->fmt_in->nBlockAlign * params->fmt_in->nSamplesPerSec)
goto unsupported;
if(params->fmt_in->nChannels == 0){
params->result = AUDCLNT_E_UNSUPPORTED_FORMAT;
return STATUS_SUCCESS;
}
unit = get_audiounit(params->flow, params->dev_id);
converter = NULL;
params->result = ca_setup_audiounit(params->flow, unit, params->fmt_in, &dev_desc, &converter);
AudioComponentInstanceDispose(unit);
if(FAILED(params->result)) goto unsupported;
if(converter) AudioConverterDispose(converter);
params->result = S_OK;
return STATUS_SUCCESS;
unsupported:
if(params->fmt_out){
struct get_mix_format_params get_mix_params =
{
.flow = params->flow,
.dev_id = params->dev_id,
.fmt = params->fmt_out,
};
get_mix_format(&get_mix_params);
params->result = get_mix_params.result;
if(SUCCEEDED(params->result)) params->result = S_FALSE;
}
else params->result = AUDCLNT_E_UNSUPPORTED_FORMAT;
return STATUS_SUCCESS;
}
unixlib_entry_t __wine_unix_call_funcs[] =
{
get_endpoint_ids,
create_stream,
release_stream,
get_mix_format,
is_format_supported,
};
......@@ -83,12 +83,23 @@ struct get_mix_format_params
HRESULT result;
};
struct is_format_supported_params
{
EDataFlow flow;
DWORD dev_id;
AUDCLNT_SHAREMODE share;
const WAVEFORMATEX *fmt_in;
WAVEFORMATEXTENSIBLE *fmt_out;
HRESULT result;
};
enum unix_funcs
{
unix_get_endpoint_ids,
unix_create_stream,
unix_release_stream,
unix_get_mix_format,
unix_is_format_supported,
};
extern unixlib_handle_t coreaudio_handle;
......
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