From ad2c7bffe7d94c79184904b14101cbc93eeb9ebd Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 31 Mar 2009 16:07:46 +0200 Subject: baseparse: Delay newsegment as long as possible. If newsegment is sent (too) early, caps may not yet be fixed/set, and downstream may not have been linked. --- gst/aacparse/gstbaseparse.c | 59 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'gst/aacparse') diff --git a/gst/aacparse/gstbaseparse.c b/gst/aacparse/gstbaseparse.c index 6d0e7f8d..4940a8e4 100644 --- a/gst/aacparse/gstbaseparse.c +++ b/gst/aacparse/gstbaseparse.c @@ -748,8 +748,42 @@ gst_base_parse_handle_and_push_buffer (GstBaseParse * parse, if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer)) last_stop += GST_BUFFER_DURATION (buffer); + /* should have caps by now */ + g_return_val_if_fail (GST_PAD_CAPS (parse->srcpad), GST_FLOW_ERROR); + gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad)); + /* and should then also be linked downstream, so safe to send some events */ + if (parse->priv->pad_mode == GST_ACTIVATE_PULL) { + if (G_UNLIKELY (parse->close_segment)) { + GST_DEBUG_OBJECT (parse, "loop sending close segment"); + gst_pad_push_event (parse->srcpad, parse->close_segment); + parse->close_segment = NULL; + } + + if (G_UNLIKELY (parse->pending_segment)) { + GST_DEBUG_OBJECT (parse, "loop push pending segment"); + gst_pad_push_event (parse->srcpad, parse->pending_segment); + parse->pending_segment = NULL; + } + } else { + if (G_UNLIKELY (parse->pending_segment)) { + GST_DEBUG_OBJECT (parse, "chain pushing a pending segment"); + gst_pad_push_event (parse->srcpad, parse->pending_segment); + parse->pending_segment = NULL; + } + } + + if (G_UNLIKELY (parse->priv->pending_events)) { + GList *l; + + for (l = parse->priv->pending_events; l != NULL; l = l->next) { + gst_pad_push_event (parse->srcpad, GST_EVENT (l->data)); + } + g_list_free (parse->priv->pending_events); + parse->priv->pending_events = NULL; + } + /* TODO: Add to seek table */ if (ret == GST_FLOW_OK) { @@ -839,9 +873,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer) bclass = GST_BASE_PARSE_GET_CLASS (parse); if (G_UNLIKELY (parse->pending_segment)) { - GST_DEBUG_OBJECT (parse, "chain pushing a pending segment"); - gst_pad_push_event (parse->srcpad, parse->pending_segment); - parse->pending_segment = NULL; parse->priv->offset = parse->priv->pending_offset; /* Make sure that adapter doesn't have any old data after @@ -854,16 +885,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer) gst_adapter_clear (parse->adapter); } - if (G_UNLIKELY (parse->priv->pending_events)) { - GList *l; - - for (l = parse->priv->pending_events; l != NULL; l = l->next) { - gst_pad_push_event (parse->srcpad, GST_EVENT (l->data)); - } - g_list_free (parse->priv->pending_events); - parse->priv->pending_events = NULL; - } - if (G_LIKELY (buffer)) { GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld", GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer)); @@ -1051,18 +1072,6 @@ gst_base_parse_loop (GstPad * pad) parse = GST_BASE_PARSE (gst_pad_get_parent (pad)); klass = GST_BASE_PARSE_GET_CLASS (parse); - if (parse->close_segment) { - GST_DEBUG_OBJECT (parse, "loop sending close segment"); - gst_pad_push_event (parse->srcpad, parse->close_segment); - parse->close_segment = NULL; - } - - if (parse->pending_segment) { - GST_DEBUG_OBJECT (parse, "loop push pending segment"); - gst_pad_push_event (parse->srcpad, parse->pending_segment); - parse->pending_segment = NULL; - } - /* TODO: Check if we reach segment stop limit */ while (TRUE) { -- cgit v1.2.1