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.
This commit is contained in:
James Ross-Gowan 2015-01-21 14:11:31 +11:00 committed by Diogo Franco (Kovensky)
parent a4b21b5a13
commit 6f9eb960c7
1 changed files with 1 additions and 2 deletions

View File

@ -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);