audioconvert: Consider channel=1, channel-mask=0x0 as mono
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Tue, 25 Jul 2017 16:37:19 +0000 (12:37 -0400)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Wed, 26 Jul 2017 13:26:39 +0000 (09:26 -0400)
channels=1 is always mono, having it 'unpositioned' does not make
sense.

This fixes pipeline such as:

  gst-validate-1.0 audiotestsrc ! audio/x-raw,channels=2,rate=44100,layout=interleaved ! audioconvert ! audioresample ! audio/x-raw, rate=44100, channels=1 ! avenc_mp2 ! fakesink

https://bugzilla.gnome.org/show_bug.cgi?id=785407

gst/audioconvert/gstaudioconvert.c

index d86b2d4..0aed324 100644 (file)
@@ -244,7 +244,7 @@ static GstCaps *
 gst_audio_convert_caps_remove_format_info (GstCaps * caps, gboolean channels)
 {
   GstStructure *st;
-  gint i, n;
+  gint i, n, n_channels;
   GstCaps *res;
   guint64 channel_mask;
 
@@ -267,7 +267,9 @@ gst_audio_convert_caps_remove_format_info (GstCaps * caps, gboolean channels)
     /* Only remove the channels and channel-mask for non-NONE layouts */
     if (gst_structure_get (st, "channel-mask", GST_TYPE_BITMASK, &channel_mask,
             NULL)) {
-      if (channel_mask != 0)
+      if (channel_mask != 0
+          || (gst_structure_get_int (st, "channels", &n_channels)
+              && (n_channels == 1)))
         remove_channels = TRUE;
     } else {
       remove_channels = TRUE;