From 3c10ed540b5ef1132d80074c4ccbd67fdfda6bae Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Wed, 21 Jan 2015 14:11:31 +1100 Subject: ao_wasapi: fix try_format logic in shared mode The MSDN documentation for IsFormatSupported says a return code of AUDCLNT_E_UNSUPPORTED_FORMAT means the function "succeeded but the specified format is not supported in exclusive mode." This seems to imply that the format is supported in shared mode, and that's what the old code assumed, however try_format would incorrectly return success with some drivers. The remarks section of the documentation contradicts that assumption. It says that in shared mode, if the audio engine does not support the caller-specified format or any similar format, ppClosestMatch is set to NULL and the function returns AUDCLNT_E_UNSUPPORTED_FORMAT. This is the same as in exclusive mode, so treat AUDCLNT_E_UNSUPPORTED_FORMAT the same regardless of opt_exclusive. In shared mode, the format selection code will fall back to the mix format, which should always be supported. --- audio/out/ao_wasapi_utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 30f1f38ae8..08fdd14930 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -324,8 +324,7 @@ static bool try_format(struct ao *ao, ao->channels.num, af_fmt_to_str(ao->format), ao->samplerate); return true; } - } if (hr == S_OK || (!state->opt_exclusive && hr == AUDCLNT_E_UNSUPPORTED_FORMAT)) { - // AUDCLNT_E_UNSUPPORTED_FORMAT here means "works in shared, doesn't in exclusive" + } else if (hr == S_OK) { if (set_ao_format(ao, &wformat.Format)) { MP_VERBOSE(ao, "%dch %s @ %dhz accepted\n", ao->channels.num, af_fmt_to_str(ao->format), samplerate); -- cgit v1.2.3