a52dec: really prefer the original number (and position) of channels
authorJulien Isorce <julien.isorce@gmail.com>
Mon, 21 May 2012 12:57:44 +0000 (14:57 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 24 May 2012 13:52:42 +0000 (15:52 +0200)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=676495

ext/a52dec/gsta52dec.c

index e59ee0d..dfcb480 100644 (file)
@@ -532,7 +532,8 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
     if (caps && gst_caps_get_size (caps) > 0) {
       GstCaps *copy = gst_caps_copy_nth (caps, 0);
       GstStructure *structure = gst_caps_get_structure (copy, 0);
-      gint channels;
+      gint orig_channels = flags ? gst_a52dec_channels (flags, NULL) : 6;
+      gint fixed_channels = 0;
       const int a52_channels[6] = {
         A52_MONO,
         A52_STEREO,
@@ -546,12 +547,15 @@ gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
        * preferred (first in the caps) downstream if possible.
        */
       gst_structure_fixate_field_nearest_int (structure, "channels",
-          flags ? gst_a52dec_channels (flags, NULL) : 6);
-      if (gst_structure_get_int (structure, "channels", &channels)
-          && channels <= 6)
-        flags = a52_channels[channels - 1];
-      else
+          orig_channels);
+
+      if (gst_structure_get_int (structure, "channels", &fixed_channels)
+          && fixed_channels <= 6) {
+        if (fixed_channels < orig_channels)
+          flags = a52_channels[fixed_channels - 1];
+      } else {
         flags = a52_channels[5];
+      }
 
       gst_caps_unref (copy);
     } else if (flags)