[0.11] gst-plugins-good: jackaudiosrc: Port to the new multichannel audio caps

Sebastian Dröge slomo at kemper.freedesktop.org
Thu Jan 5 01:37:30 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: 531d611f839febaf0a2367aafdf740b52e6236fa
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=531d611f839febaf0a2367aafdf740b52e6236fa

Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date:   Wed Jan  4 14:52:46 2012 +0100

jackaudiosrc: Port to the new multichannel audio caps

---

 ext/jack/gstjackaudiosrc.c |    2 +-
 ext/jack/gstjackutil.c     |   48 ++++++++++++++++++++-----------------------
 ext/jack/gstjackutil.h     |    3 +-
 3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/ext/jack/gstjackaudiosrc.c b/ext/jack/gstjackaudiosrc.c
index 1453ba1..34d48ff 100644
--- a/ext/jack/gstjackaudiosrc.c
+++ b/ext/jack/gstjackaudiosrc.c
@@ -428,7 +428,7 @@ gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
   if (!gst_jack_audio_src_allocate_channels (src, channels))
     goto out_of_ports;
 
-  gst_jack_set_layout_on_caps (&spec->caps, channels);
+  gst_jack_set_layout (buf, spec);
 
   buffer_size = jack_get_buffer_size (client);
 
diff --git a/ext/jack/gstjackutil.c b/ext/jack/gstjackutil.c
index cde84d8..e21d004 100644
--- a/ext/jack/gstjackutil.c
+++ b/ext/jack/gstjackutil.c
@@ -18,12 +18,12 @@
  */
 
 #include "gstjackutil.h"
-#include <gst/audio/multichannel.h>
+#include <gst/audio/audio.h>
 
 static const GstAudioChannelPosition default_positions[8][8] = {
   /* 1 channel */
   {
-        GST_AUDIO_CHANNEL_POSITION_FRONT_MONO,
+        GST_AUDIO_CHANNEL_POSITION_MONO,
       },
   /* 2 channels */
   {
@@ -34,7 +34,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
   {
         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
-        GST_AUDIO_CHANNEL_POSITION_LFE, /* or FRONT_CENTER for 3.0? */
+        GST_AUDIO_CHANNEL_POSITION_LFE1,        /* or FRONT_CENTER for 3.0? */
       },
   /* 4 channels (4.0 or 3.1?) */
   {
@@ -58,7 +58,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
-        GST_AUDIO_CHANNEL_POSITION_LFE,
+        GST_AUDIO_CHANNEL_POSITION_LFE1,
       },
   /* 7 channels */
   {
@@ -67,7 +67,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
-        GST_AUDIO_CHANNEL_POSITION_LFE,
+        GST_AUDIO_CHANNEL_POSITION_LFE1,
         GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
       },
   /* 8 channels */
@@ -77,7 +77,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
-        GST_AUDIO_CHANNEL_POSITION_LFE,
+        GST_AUDIO_CHANNEL_POSITION_LFE1,
         GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
         GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
       }
@@ -87,28 +87,24 @@ static const GstAudioChannelPosition default_positions[8][8] = {
 /* if channels are less than or equal to 8, we set a default layout,
  * otherwise set layout to an array of GST_AUDIO_CHANNEL_POSITION_NONE */
 void
-gst_jack_set_layout_on_caps (GstCaps ** caps, gint channels)
+gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec * spec)
 {
-  int c;
-  GValue pos = { 0 };
-  GValue chanpos = { 0 };
-  gst_caps_unref (*caps);
+  gint i;
 
-  if (channels <= 8) {
-    g_assert (channels >= 1);
-    gst_audio_set_channel_positions (gst_caps_get_structure (*caps, 0),
-        default_positions[channels - 1]);
+  if (spec->info.channels <= 8) {
+    for (i = 0; i < spec->info.channels; i++)
+      spec->info.position[i] = default_positions[spec->info.channels - 1][i];
+    gst_audio_channel_positions_to_valid_order (spec->info.position,
+        spec->info.channels);
+    gst_audio_ring_buffer_set_channel_positions (buffer,
+        default_positions[spec->info.channels - 1]);
   } else {
-    g_value_init (&chanpos, GST_TYPE_ARRAY);
-    g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);
-    for (c = 0; c < channels; c++) {
-      g_value_set_enum (&pos, GST_AUDIO_CHANNEL_POSITION_NONE);
-      gst_value_array_append_value (&chanpos, &pos);
-    }
-    g_value_unset (&pos);
-    gst_structure_set_value (gst_caps_get_structure (*caps, 0),
-        "channel-positions", &chanpos);
-    g_value_unset (&chanpos);
+    spec->info.flags |= GST_AUDIO_FLAG_UNPOSITIONED;
+    for (i = 0; i < G_N_ELEMENTS (spec->info.position); i++)
+      spec->info.position[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
+    gst_audio_ring_buffer_set_channel_positions (buffer, spec->info.position);
   }
-  gst_caps_ref (*caps);
+
+  gst_caps_unref (spec->caps);
+  spec->caps = gst_audio_info_to_caps (&spec->info);
 }
diff --git a/ext/jack/gstjackutil.h b/ext/jack/gstjackutil.h
index e330afd..b3704ca 100644
--- a/ext/jack/gstjackutil.h
+++ b/ext/jack/gstjackutil.h
@@ -23,8 +23,9 @@
 #define _GST_JACK_UTIL_H_
 
 #include <gst/gst.h>
+#include <gst/audio/gstaudioringbuffer.h>
 
 void
-gst_jack_set_layout_on_caps (GstCaps **caps, gint channels);
+gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec *spec);
 
 #endif  // _GST_JACK_UTIL_H_



More information about the gstreamer-commits mailing list