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 <pkv@obsproject.com>
This commit is contained in:
pkv 2022-05-05 21:54:36 +02:00 committed by Ryan Foster
parent 1dc3da4163
commit 5e4081e563

View File

@ -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 &&