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
This commit is contained in:
Guillaume Desmottes 2016-03-21 16:34:37 +01:00 committed by Nicolas Dufresne
parent 7c5dfd713c
commit 6e7fa6659f

View file

@ -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;
}