diff options
author | Kevin Mitchell <kevmitch@gmail.com> | 2014-11-30 05:38:06 -0800 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2015-01-25 17:00:12 +0900 |
commit | d56a1112d29531ccd6c0f7e917b9468cc100ab54 (patch) | |
tree | f02ede03cf0b8fa5cb328c41e3336937f61d90f0 | |
parent | b1292c044a0f53a6e2a8ea8e5f0cb351be4fec28 (diff) | |
download | mpv-d56a1112d29531ccd6c0f7e917b9468cc100ab54.tar.bz2 mpv-d56a1112d29531ccd6c0f7e917b9468cc100ab54.tar.xz |
ao/wasapi: show actual waveformat tried
also remove bogus ao_format
-rwxr-xr-x | audio/out/ao_wasapi_utils.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 0d95b00678..03e7ccad16 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -187,6 +187,34 @@ static void set_waveformat(WAVEFORMATEXTENSIBLE *wformat, WORD bytepersample, wformat->dwChannelMask = chanmask; } +static char *waveformat_to_str_buf(char *buf, size_t buf_size, const WAVEFORMATEX *wf) +{ + char* type = "?"; + switch(wf->wFormatTag) { + case WAVE_FORMAT_EXTENSIBLE: + { + WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; + if ( !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, + &wformat->SubFormat) ) + type = "float"; + else if ( !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_PCM, + &wformat->SubFormat) ) + type = "s"; + break; + } + case WAVE_FORMAT_IEEE_FLOAT: + type = "float"; + break; + case WAVE_FORMAT_PCM: + type = "s"; + break; + } + snprintf(buf, buf_size, "%"PRIu16"ch %s%"PRIu16" @ %"PRIu32"hz", + wf->nChannels, type, wf->wBitsPerSample, (unsigned)wf->nSamplesPerSec); + return buf; +} +#define waveformat_to_str(wf) waveformat_to_str_buf((char[32]){0}, 32, (wf)) + static bool waveformat_is_float(WAVEFORMATEX *wf) { switch(wf->wFormatTag) { @@ -273,13 +301,7 @@ static bool try_format(struct ao *ao, WAVEFORMATEXTENSIBLE wformat; set_waveformat(&wformat, bits / 8, is_float, samplerate, channels.num, mp_chmap_to_waveext(&channels)); - - int af_format = format_set_bits(ao->format, bits, is_float); - if (!af_format) - return false; - - MP_VERBOSE(ao, "Trying %dch %s @ %dhz\n", - channels.num, af_fmt_to_str(af_format), samplerate); + MP_VERBOSE(ao, "Trying %s\n", waveformat_to_str(&wformat.Format)); WAVEFORMATEX *closestMatch; HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient, @@ -302,7 +324,7 @@ static bool try_format(struct ao *ao, // AUDCLNT_E_UNSUPPORTED_FORMAT here means "works in shared, doesn't in exclusive" if (set_ao_format(ao, wformat)) { MP_VERBOSE(ao, "%dch %s @ %dhz accepted\n", - ao->channels.num, af_fmt_to_str(af_format), samplerate); + ao->channels.num, af_fmt_to_str(ao->format), samplerate); return true; } } |