ext/a52dec/gsta52dec.*: Fix channel re-negotiation on a change of the incoming stream.

Original commit message from CVS:
* ext/a52dec/gsta52dec.c:
* ext/a52dec/gsta52dec.h:
Fix channel re-negotiation on a change of the incoming stream.
Patch By: Thijs Vermeir <thijsvermeir@gmail.com>
Fixes: #551660
This commit is contained in:
Thijs Vermeir 2008-09-27 00:20:48 +00:00 committed by Jan Schmidt
parent 0df8ea9ebd
commit 4e7129f1d6
3 changed files with 29 additions and 8 deletions

View file

@ -1,3 +1,12 @@
2008-09-27 Jan Schmidt <jan.schmidt@sun.com>
* ext/a52dec/gsta52dec.c:
* ext/a52dec/gsta52dec.h:
Fix channel re-negotiation on a change of the incoming stream.
Patch By: Thijs Vermeir <thijsvermeir@gmail.com>
Fixes: #551660
2008-09-26 Wim Taymans <wim.taymans@collabora.co.uk> 2008-09-26 Wim Taymans <wim.taymans@collabora.co.uk>
* ext/amrnb/amrnbenc.c: (gst_amrnbenc_chain), * ext/amrnb/amrnbenc.c: (gst_amrnbenc_chain),

View file

@ -235,7 +235,6 @@ gst_a52dec_init (GstA52Dec * a52dec)
a52dec->srcpad = a52dec->srcpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass, gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
"src"), "src"); "src"), "src");
gst_pad_use_fixed_caps (a52dec->srcpad);
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad); gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad);
a52dec->request_channels = A52_CHANNEL; a52dec->request_channels = A52_CHANNEL;
@ -576,9 +575,13 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data,
* accept - this allows a52dec to do downmixing in preference to a * accept - this allows a52dec to do downmixing in preference to a
* downstream element such as audioconvert. * downstream element such as audioconvert.
*/ */
if (a52dec->request_channels == A52_CHANNEL) { if (a52dec->request_channels != A52_CHANNEL) {
flags = a52dec->request_channels;
} else if (a52dec->flag_update) {
GstCaps *caps; GstCaps *caps;
a52dec->flag_update = FALSE;
caps = gst_pad_get_allowed_caps (a52dec->srcpad); caps = gst_pad_get_allowed_caps (a52dec->srcpad);
if (caps && gst_caps_get_size (caps) > 0) { if (caps && gst_caps_get_size (caps) > 0) {
GstCaps *copy = gst_caps_copy_nth (caps, 0); GstCaps *copy = gst_caps_copy_nth (caps, 0);
@ -600,22 +603,22 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data,
flags ? gst_a52dec_channels (flags, NULL) : 6); flags ? gst_a52dec_channels (flags, NULL) : 6);
gst_structure_get_int (structure, "channels", &channels); gst_structure_get_int (structure, "channels", &channels);
if (channels <= 6) if (channels <= 6)
a52dec->request_channels = a52_channels[channels - 1]; flags = a52_channels[channels - 1];
else else
a52dec->request_channels = a52_channels[5]; flags = a52_channels[5];
gst_caps_unref (copy); gst_caps_unref (copy);
} else if (flags) } else if (flags)
a52dec->request_channels = a52dec->stream_channels; flags = a52dec->stream_channels;
else else
a52dec->request_channels = A52_3F2R | A52_LFE; flags = A52_3F2R | A52_LFE;
if (caps) if (caps)
gst_caps_unref (caps); gst_caps_unref (caps);
} else {
flags = a52dec->using_channels;
} }
/* process */ /* process */
flags = a52dec->request_channels; /* | A52_ADJUST_LEVEL; */
a52dec->level = 1; a52dec->level = 1;
if (a52_frame (a52dec->state, data, &flags, &a52dec->level, a52dec->bias)) { if (a52_frame (a52dec->state, data, &flags, &a52dec->level, a52dec->bias)) {
GST_WARNING ("a52_frame error"); GST_WARNING ("a52_frame error");
@ -812,6 +815,11 @@ gst_a52dec_chain_raw (GstPad * pad, GstBuffer * buf)
flags = 0; flags = 0;
while (size >= 7) { while (size >= 7) {
length = a52_syncinfo (data, &flags, &sample_rate, &bit_rate); length = a52_syncinfo (data, &flags, &sample_rate, &bit_rate);
if (flags != a52dec->prev_flags)
a52dec->flag_update = TRUE;
a52dec->prev_flags = flags;
if (length == 0) { if (length == 0) {
/* no sync */ /* no sync */
data++; data++;
@ -873,6 +881,7 @@ gst_a52dec_change_state (GstElement * element, GstStateChange transition)
a52dec->bias = 0; a52dec->bias = 0;
a52dec->time = 0; a52dec->time = 0;
a52dec->sent_segment = FALSE; a52dec->sent_segment = FALSE;
a52dec->flag_update = TRUE;
gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&a52dec->segment, GST_FORMAT_UNDEFINED);
break; break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: case GST_STATE_CHANGE_PAUSED_TO_PLAYING:

View file

@ -51,6 +51,9 @@ struct _GstA52Dec {
gboolean sent_segment; gboolean sent_segment;
gboolean discont; gboolean discont;
gboolean flag_update;
int prev_flags;
int bit_rate; int bit_rate;
int sample_rate; int sample_rate;
int stream_channels; int stream_channels;