audioringbuffer: don't attempt to reorder position-less channels

As said in its doc GST_AUDIO_CHANNEL_POSITION_NONE is meant to be used
for "position-less channels, e.g. from a sound card that records 1024
channels; mutually exclusive with any other channel position".

But at the moment using such positions would raise a
'g_return_if_reached' warning as gst_audio_get_channel_reorder_map()
would reject it.

Fix this by preventing any attempt to reorder in such case as that's not
what we want anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=763799
This commit is contained in:
Guillaume Desmottes 2016-03-21 16:29:39 +01:00 committed by Nicolas Dufresne
parent 1c56cfa144
commit 7c5dfd713c

View file

@ -1952,6 +1952,23 @@ gst_audio_ring_buffer_may_start (GstAudioRingBuffer * buf, gboolean allowed)
g_atomic_int_set (&buf->may_start, allowed);
}
/* GST_AUDIO_CHANNEL_POSITION_NONE is used for position-less
* mutually exclusive channels. In this case we should not attempt
* to do any reordering.
*/
static gboolean
position_less_channels (const GstAudioChannelPosition * pos, guint channels)
{
guint i;
for (i = 0; i < channels; i++) {
if (pos[i] != GST_AUDIO_CHANNEL_POSITION_NONE)
return FALSE;
}
return TRUE;
}
/**
* gst_audio_ring_buffer_set_channel_positions:
* @buf: the #GstAudioRingBuffer
@ -1977,6 +1994,11 @@ gst_audio_ring_buffer_set_channel_positions (GstAudioRingBuffer * buf,
if (memcmp (position, to, channels * sizeof (to[0])) == 0)
return;
if (position_less_channels (position, channels)) {
GST_LOG_OBJECT (buf, "position-less channels, no need to reorder");
return;
}
buf->need_reorder = FALSE;
if (!gst_audio_get_channel_reorder_map (channels, position, to,
buf->channel_reorder_map))