mirror of https://github.com/mpv-player/mpv
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:
parent
a4b21b5a13
commit
6f9eb960c7
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue