audioringbuffer: don't attempt to reorder position-less channels
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 21 Mar 2016 15:29:39 +0000 (16:29 +0100)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 12 Apr 2016 18:48:30 +0000 (14:48 -0400)
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

index 08bb38b..618e3a9 100644 (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))