[0.11] gst-plugins-base: audio: Add validity check for the UNPOSITIONED audio flag

Sebastian Dröge slomo at kemper.freedesktop.org
Wed Jan 11 01:45:39 PST 2012


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

Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date:   Wed Jan 11 10:44:37 2012 +0100

audio: Add validity check for the UNPOSITIONED audio flag

Also reset the flag when parsing caps.

---

 gst-libs/gst/audio/audio.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c
index b6b0679..2075373 100644
--- a/gst-libs/gst/audio/audio.c
+++ b/gst-libs/gst/audio/audio.c
@@ -529,6 +529,8 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
 
   GST_DEBUG ("parsing caps %" GST_PTR_FORMAT, caps);
 
+  info->flags = 0;
+
   str = gst_caps_get_structure (caps, 0);
 
   if (!gst_structure_has_name (str, "audio/x-raw"))
@@ -654,6 +656,7 @@ gst_audio_info_to_caps (const GstAudioInfo * info)
   GstCaps *caps;
   const gchar *format;
   const gchar *layout;
+  GstAudioFlags flags;
 
   g_return_val_if_fail (info != NULL, NULL);
   g_return_val_if_fail (info->finfo != NULL, NULL);
@@ -669,6 +672,13 @@ gst_audio_info_to_caps (const GstAudioInfo * info)
   else
     g_return_val_if_reached (NULL);
 
+  flags = info->flags;
+  if ((flags & GST_AUDIO_FLAG_UNPOSITIONED) && info->channels > 1
+      && info->position[0] != GST_AUDIO_CHANNEL_POSITION_NONE) {
+    flags &= ~GST_AUDIO_FLAG_UNPOSITIONED;
+    GST_WARNING ("Unpositioned flag set but channel positions present");
+  }
+
   caps = gst_caps_new_simple ("audio/x-raw",
       "format", G_TYPE_STRING, format,
       "layout", G_TYPE_STRING, layout,
@@ -679,7 +689,7 @@ gst_audio_info_to_caps (const GstAudioInfo * info)
       || info->position[0] != GST_AUDIO_CHANNEL_POSITION_MONO) {
     guint64 channel_mask = 0;
 
-    if ((info->flags & GST_AUDIO_FLAG_UNPOSITIONED)) {
+    if ((flags & GST_AUDIO_FLAG_UNPOSITIONED)) {
       channel_mask = 0;
     } else {
       if (!check_valid_channel_positions (info->position, info->channels,



More information about the gstreamer-commits mailing list