From b2389c2108b6f643e4c0879d22059530d4d734c5 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 2 Feb 2011 16:49:04 +0100 Subject: [PATCH] tagdemux: also push cached events downstream when operating in pull mode Otherwise, having 2 tagdemux in a row followed by an element operating in pull mode will make the second tagdemux implictly eat the first tagdemux' tag event(s). Fixes (part of) #641047. --- gst-libs/gst/tag/gsttagdemux.c | 41 +++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/gst-libs/gst/tag/gsttagdemux.c b/gst-libs/gst/tag/gsttagdemux.c index fdc09b83ce..8bb331434e 100644 --- a/gst-libs/gst/tag/gsttagdemux.c +++ b/gst-libs/gst/tag/gsttagdemux.c @@ -156,6 +156,7 @@ static GstStateChangeReturn gst_tag_demux_change_state (GstElement * element, static gboolean gst_tag_demux_pad_query (GstPad * pad, GstQuery * query); static const GstQueryType *gst_tag_demux_get_query_types (GstPad * pad); static gboolean gst_tag_demux_get_upstream_size (GstTagDemux * tagdemux); +static void gst_tag_demux_send_pending_events (GstTagDemux * tagdemux); static void gst_tag_demux_send_tag_event (GstTagDemux * tagdemux); static gboolean gst_tag_demux_send_new_segment (GstTagDemux * tagdemux); @@ -668,8 +669,6 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf) return GST_FLOW_UNEXPECTED; } if (outbuf) { - GList *events; - if (G_UNLIKELY (demux->priv->srcpad == NULL)) { gst_buffer_unref (outbuf); return GST_FLOW_ERROR; @@ -685,17 +684,7 @@ gst_tag_demux_chain (GstPad * pad, GstBuffer * buf) } /* send any pending events we cached */ - GST_OBJECT_LOCK (demux); - events = demux->priv->pending_events; - demux->priv->pending_events = NULL; - GST_OBJECT_UNLOCK (demux); - - while (events != NULL) { - GST_DEBUG_OBJECT (demux->priv->srcpad, "sending cached %s event: %" - GST_PTR_FORMAT, GST_EVENT_TYPE_NAME (events->data), events->data); - gst_pad_push_event (demux->priv->srcpad, GST_EVENT (events->data)); - events = g_list_delete_link (events, events); - } + gst_tag_demux_send_pending_events (demux); /* Send our own pending tag event */ if (demux->priv->send_tag_event) { @@ -1333,6 +1322,13 @@ gst_tag_demux_src_getrange (GstPad * srcpad, { GstTagDemux *demux = GST_TAG_DEMUX (GST_PAD_PARENT (srcpad)); + /* downstream in pull mode won't miss a newsegment event, + * but it likely appreciates other (tag) events */ + if (demux->priv->need_newseg) { + gst_tag_demux_send_pending_events (demux); + demux->priv->need_newseg = FALSE; + } + if (demux->priv->send_tag_event) { gst_tag_demux_send_tag_event (demux); demux->priv->send_tag_event = FALSE; @@ -1418,6 +1414,25 @@ gst_tag_demux_get_query_types (GstPad * pad) return types; } +static void +gst_tag_demux_send_pending_events (GstTagDemux * demux) +{ + GList *events; + + /* send any pending events we cached */ + GST_OBJECT_LOCK (demux); + events = demux->priv->pending_events; + demux->priv->pending_events = NULL; + GST_OBJECT_UNLOCK (demux); + + while (events != NULL) { + GST_DEBUG_OBJECT (demux->priv->srcpad, "sending cached %s event: %" + GST_PTR_FORMAT, GST_EVENT_TYPE_NAME (events->data), events->data); + gst_pad_push_event (demux->priv->srcpad, GST_EVENT (events->data)); + events = g_list_delete_link (events, events); + } +} + static void gst_tag_demux_send_tag_event (GstTagDemux * demux) {