From 6e7fa6659f3dbf0efc3d4aaeb2186d4e52a7ee70 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Mar 2016 16:34:37 +0100 Subject: [PATCH] alsa: properly convert position-less channels from ALSA The only way for ALSA to expose a position-less multi channels is to return an array full of SND_CHMAP_MONO. Converting this to a GST_AUDIO_CHANNEL_POSITION_MONO array would be invalid as GST_AUDIO_CHANNEL_POSITION_MONO is meant to be used only with one channel. Fix this by using GST_AUDIO_CHANNEL_POSITION_NONE which is meant to be used for position-less channels. https://bugzilla.gnome.org/show_bug.cgi?id=763799 --- ext/alsa/gstalsa.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index b9bb2919f4..a44e6e19b5 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -750,6 +750,7 @@ alsa_chmap_to_channel_positions (const snd_pcm_chmap_t * chmap, GstAudioChannelPosition * pos) { int c; + gboolean all_mono = TRUE; for (c = 0; c < chmap->channels; c++) { if (chmap->pos[c] > SND_CHMAP_LAST) @@ -758,7 +759,22 @@ alsa_chmap_to_channel_positions (const snd_pcm_chmap_t * chmap, if (!pos[c]) return FALSE; pos[c]--; + + if (pos[c] != GST_AUDIO_CHANNEL_POSITION_MONO) + all_mono = FALSE; } + + if (all_mono && chmap->channels > 1) { + /* GST_AUDIO_CHANNEL_POSITION_MONO can only be used with 1 channel and + * GST_AUDIO_CHANNEL_POSITION_NONE is meant to be used for position-less + * multi channels. + * Converting as ALSA can only express such configuration by using an array + * full of SND_CHMAP_MONO. + */ + for (c = 0; c < chmap->channels; c++) + pos[c] = GST_AUDIO_CHANNEL_POSITION_NONE; + } + return TRUE; }