summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-02-02 20:02:57 +0100
committerDudemanguy <random342@airmail.cc>2023-09-29 02:35:10 +0000
commit4f0b6545032ee6b999ed3c8cf0ca3731c5c988c8 (patch)
tree879c21ab4c859b55d73afa21315a060dbdadfe9e
parent0728e4778f711c12a0c94add133befdbba1e4c86 (diff)
downloadmpv-4f0b6545032ee6b999ed3c8cf0ca3731c5c988c8.tar.bz2
mpv-4f0b6545032ee6b999ed3c8cf0ca3731c5c988c8.tar.xz
wasapi: clamp number of output channels to 8
This is the most supported in standard layout, if we request more it tends to fallback to stereo instead. Also channels mask is 32-bit and it can get truncated.
-rw-r--r--audio/out/ao_wasapi_utils.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index d2261bfb6c..07c7ddb43f 100644
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -143,7 +143,19 @@ static void set_waveformat(WAVEFORMATEXTENSIBLE *wformat,
wformat->SubFormat = *format_to_subtype(format->mp_format);
wformat->Samples.wValidBitsPerSample = format->used_msb;
- wformat->dwChannelMask = mp_chmap_to_waveext(channels);
+
+ uint64_t chans = mp_chmap_to_waveext(channels);
+ wformat->dwChannelMask = chans;
+
+ if (wformat->Format.nChannels > 8 || wformat->dwChannelMask != chans) {
+ // IAudioClient::IsFormatSupported tend to fallback to stereo for closest
+ // format match when there are more channels. Remix to standard layout.
+ // Also if input channel mask has channels outside 32-bits override it
+ // and hope for the best...
+ wformat->dwChannelMask = KSAUDIO_SPEAKER_7POINT1_SURROUND;
+ wformat->Format.nChannels = 8;
+ }
+
update_waveformat_datarate(wformat);
}