From 6f0f28af45a432304fe0d4605ad07ffbfd09d3dc Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Mon, 21 May 2012 14:57:44 +0200 Subject: [PATCH] a52dec: really prefer the original number (and position) of channels Fixes https://bugzilla.gnome.org/show_bug.cgi?id=676495 --- ext/a52dec/gsta52dec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c index e59ee0d762..dfcb480fa1 100644 --- a/ext/a52dec/gsta52dec.c +++ b/ext/a52dec/gsta52dec.c @@ -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)