audio: add flag for unpositioned layout
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 2 Jan 2012 14:01:58 +0000 (15:01 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 2 Jan 2012 14:01:58 +0000 (15:01 +0100)
Check if thr layout is explicitly unpositioned and set a flag in the
audio info structure.

gst-libs/gst/audio/audio.c
gst-libs/gst/audio/audio.h

index 2f43b5f..ac32a88 100644 (file)
@@ -412,6 +412,11 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
     for (i = 0; i < max_pos; i++) {
       pos_val_entry = gst_value_array_get_value (pos_val_arr, i);
       info->position[i] = g_value_get_enum (pos_val_entry);
+
+      /* the unpositioned flag is set as soon as one of the channels has an
+       * explicit NONE positioning */
+      if (info->position[i] == GST_AUDIO_CHANNEL_POSITION_NONE)
+        info->flags |= GST_AUDIO_FLAG_UNPOSITIONED;
     }
   } else {
     info->flags |= GST_AUDIO_FLAG_DEFAULT_POSITIONS;
index 60421ad..fd47f63 100644 (file)
@@ -257,12 +257,15 @@ void           gst_audio_format_fill_silence     (const GstAudioFormatInfo *info
  * @GST_AUDIO_FLAG_NONE: no valid flag
  * @GST_AUDIO_FLAG_DEFAULT_POSITIONS: position array
  *     contains the default layout for the number of channels.
+ * @GST_AUDIO_FLAG_UNPOSITIONED: the position array explicitly
+ *     contains unpositioned channels.
  *
  * Extra audio flags
  */
 typedef enum {
   GST_AUDIO_FLAG_NONE              = 0,
-  GST_AUDIO_FLAG_DEFAULT_POSITIONS = (1 << 0)
+  GST_AUDIO_FLAG_DEFAULT_POSITIONS = (1 << 0),
+  GST_AUDIO_FLAG_UNPOSITIONED      = (1 << 1)
 } GstAudioFlags;
 
 /**
@@ -312,6 +315,7 @@ GType gst_audio_info_get_type        (void);
 
 #define GST_AUDIO_INFO_FLAGS(info)           ((info)->flags)
 #define GST_AUDIO_INFO_HAS_DEFAULT_POSITIONS(info) ((info)->flags & GST_AUDIO_FLAG_DEFAULT_POSITIONS)
+#define GST_AUDIO_INFO_IS_UNPOSITIONED(info) ((info)->flags & GST_AUDIO_FLAG_UNPOSITIONED)
 
 #define GST_AUDIO_INFO_RATE(info)            ((info)->rate)
 #define GST_AUDIO_INFO_CHANNELS(info)        ((info)->channels)