From 7c5dfd713c4d352e6eddbcbabae21d389a8b83e2 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 21 Mar 2016 16:29:39 +0100 Subject: [PATCH] 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 --- gst-libs/gst/audio/gstaudioringbuffer.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gst-libs/gst/audio/gstaudioringbuffer.c b/gst-libs/gst/audio/gstaudioringbuffer.c index 08bb38b364..618e3a9d0e 100644 --- a/gst-libs/gst/audio/gstaudioringbuffer.c +++ b/gst-libs/gst/audio/gstaudioringbuffer.c @@ -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))