From 5e4081e5637c7b6761ce54d5aef344fa85414e29 Mon Sep 17 00:00:00 2001 From: pkv Date: Thu, 5 May 2022 21:54:36 +0200 Subject: [PATCH] vlc-source: Fix surround sound not properly downmixed This fixes issue https://github.com/obsproject/obs-studio/issues/6295 . libvlc does some downmixing/upmixing when the number of channels requested is less than the number of channels of the source. We take advantage of that feature to avoid doing it with swresample because we're missing info that libvlc is not giving (the exact channel layout of the source). Signed-off-by: pkv --- plugins/vlc-video/vlc-video-source.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/vlc-video/vlc-video-source.c b/plugins/vlc-video/vlc-video-source.c index 6799f624c..a59be7be5 100644 --- a/plugins/vlc-video/vlc-video-source.c +++ b/plugins/vlc-video/vlc-video-source.c @@ -458,10 +458,13 @@ static int vlcs_audio_setup(void **p_data, char *format, unsigned *rate, { struct vlc_source *c = *p_data; enum audio_format new_audio_format; + struct obs_audio_info aoi; + obs_get_audio_info(&aoi); + int out_channels = (int)get_audio_channels(aoi.speakers); new_audio_format = convert_vlc_audio_format(format); - if (*channels > 8) - *channels = 8; + if (*channels > out_channels) + *channels = out_channels; /* don't free audio data if the data is the same format */ if (c->audio.format == new_audio_format &&