From 5cf1668a8f450784e421782544f6f62b61b3e08c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 18 Dec 2007 17:40:34 +0000 Subject: [PATCH] ext/flac/gstflacdec.*: Remove some unused vars. Original commit message from CVS: * ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders), (gst_flac_dec_update_metadata), (gst_flac_dec_metadata_callback), (gst_flac_dec_write): * ext/flac/gstflacdec.h: Remove some unused vars. Do more cleanup of leftover events and tags. Output tags after the segment event. Fixes #504018. --- ChangeLog | 10 ++++++++++ common | 2 +- ext/flac/gstflacdec.c | 41 ++++++++++++++++++++++++++--------------- ext/flac/gstflacdec.h | 2 +- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb35cb8da..3d3d425be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-12-18 Wim Taymans + + * ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders), + (gst_flac_dec_update_metadata), (gst_flac_dec_metadata_callback), + (gst_flac_dec_write): + * ext/flac/gstflacdec.h: + Remove some unused vars. + Do more cleanup of leftover events and tags. + Output tags after the segment event. Fixes #504018. + 2007-12-18 Tim-Philipp Müller * gst/avi/gstavisubtitle.c: (IS_BOM_UTF8), (IS_BOM_UTF16_BE), diff --git a/common b/common index 67b8f4e3c..970759077 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 67b8f4e3c576945f4d778c9040876af3a5a0756e +Subproject commit 970759077c95ee4e85650db023ac6f974e2aa5e1 diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index c2aa24333..23fa79cee 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -259,6 +259,19 @@ gst_flac_dec_reset_decoders (GstFlacDec * flacdec) flacdec->adapter = NULL; } + if (flacdec->close_segment) { + gst_event_unref (flacdec->close_segment); + flacdec->close_segment = NULL; + } + if (flacdec->start_segment) { + gst_event_unref (flacdec->start_segment); + flacdec->start_segment = NULL; + } + if (flacdec->tags) { + gst_tag_list_free (flacdec->tags); + flacdec->tags = NULL; + } + flacdec->segment.last_stop = 0; flacdec->offset = 0; flacdec->init = TRUE; @@ -371,7 +384,10 @@ gst_flac_dec_update_metadata (GstFlacDec * flacdec, gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_AUDIO_CODEC, "FLAC", NULL); - gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad, list); + if (flacdec->tags) + gst_tag_list_free (flacdec->tags); + flacdec->tags = list; + return TRUE; } @@ -900,20 +916,13 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, "rate", G_TYPE_INT, frame->header.sample_rate, "channels", G_TYPE_INT, channels, NULL); - if (!gst_pad_set_caps (flacdec->srcpad, caps)) { - GST_ELEMENT_ERROR (flacdec, CORE, NEGOTIATION, (NULL), - ("Failed to negotiate caps %" GST_PTR_FORMAT, caps)); - flacdec->last_flow = GST_FLOW_ERROR; - gst_caps_unref (caps); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - gst_caps_unref (caps); - flacdec->depth = depth; flacdec->width = width; flacdec->channels = channels; flacdec->sample_rate = frame->header.sample_rate; + + gst_pad_set_caps (flacdec->srcpad, caps); + gst_caps_unref (caps); } if (flacdec->close_segment) { @@ -925,6 +934,12 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, flacdec->start_segment = NULL; } + if (flacdec->tags) { + gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad, + flacdec->tags); + flacdec->tags = NULL; + } + ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad, flacdec->segment.last_stop, samples * channels * (width / 8), GST_PAD_CAPS (flacdec->srcpad), &outbuf); @@ -1247,7 +1262,6 @@ gst_flac_dec_sink_event (GstPad * pad, GstEvent * event) GST_DEBUG_OBJECT (dec, "newsegment event in TIME format => framed"); dec->framed = TRUE; res = gst_pad_push_event (dec->srcpad, event); - dec->need_newsegment = FALSE; /* this won't work for the first newsegment event though ... */ if (gst_flac_dec_convert_src (dec->srcpad, GST_FORMAT_TIME, cur, @@ -1264,7 +1278,6 @@ gst_flac_dec_sink_event (GstPad * pad, GstEvent * event) GST_DEBUG_OBJECT (dec, "newsegment event in %s format => not framed", gst_format_get_name (fmt)); dec->framed = FALSE; - dec->need_newsegment = TRUE; gst_event_unref (event); res = TRUE; } @@ -1962,8 +1975,6 @@ gst_flac_dec_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: - flacdec->segment.last_stop = 0; - flacdec->need_newsegment = TRUE; flacdec->seeking = FALSE; flacdec->channels = 0; flacdec->depth = 0; diff --git a/ext/flac/gstflacdec.h b/ext/flac/gstflacdec.h index 00ed6ee1f..b68986d29 100644 --- a/ext/flac/gstflacdec.h +++ b/ext/flac/gstflacdec.h @@ -61,7 +61,6 @@ struct _GstFlacDec { GstPad *srcpad; gboolean init; - gboolean need_newsegment; guint64 offset; /* current byte offset of input */ @@ -75,6 +74,7 @@ struct _GstFlacDec { gboolean discont; GstEvent *close_segment; GstEvent *start_segment; + GstTagList *tags; GstFlowReturn last_flow; /* the last flow return received from either * gst_pad_push or gst_pad_buffer_alloc */ -- 2.34.1