From d0b25845ec6f2da545aeea550ad37d06d765f764 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 3 Dec 2009 08:58:08 +0000 Subject: [PATCH] matroskademux: only send pending tags with newsegment events Send pending tags only from the streaming thread, just after we've sent the newsegment event, not with e.g. flush-start. This not only does the right thing, but also makes sure we're not trampling over variables set up in the streaming thread from the seeking thread in case someone tries to issue a seek just as the demuxer is parsing the headers. Fixes #601617. Spotted by Ognyan Tonchev. --- gst/matroska/matroska-demux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 1246e42..c55790c 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2042,6 +2042,7 @@ gst_matroska_demux_found_global_tag (GstMatroskaDemux * demux, static gboolean gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event) { + gboolean is_newsegment; gboolean ret = TRUE; gint i; @@ -2050,6 +2051,9 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event) GST_DEBUG_OBJECT (demux, "Sending event of type %s to all source pads", GST_EVENT_TYPE_NAME (event)); + is_newsegment = (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT); + + /* FIXME: access to demux->src is not thread-safe here */ g_assert (demux->src->len == demux->num_streams); for (i = 0; i < demux->src->len; i++) { GstMatroskaTrackContext *stream; @@ -2058,7 +2062,8 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event) gst_event_ref (event); gst_pad_push_event (stream->pad, event); - if (G_UNLIKELY (stream->pending_tags)) { + /* FIXME: send global tags before stream tags */ + if (G_UNLIKELY (is_newsegment && stream->pending_tags != NULL)) { GST_DEBUG_OBJECT (demux, "Sending pending_tags %p for pad %s:%s : %" GST_PTR_FORMAT, stream->pending_tags, GST_DEBUG_PAD_NAME (stream->pad), stream->pending_tags); @@ -2068,7 +2073,7 @@ gst_matroska_demux_send_event (GstMatroskaDemux * demux, GstEvent * event) } } - if (G_UNLIKELY (demux->global_tags)) { + if (G_UNLIKELY (is_newsegment && demux->global_tags != NULL)) { gst_tag_list_add (demux->global_tags, GST_TAG_MERGE_REPLACE, GST_TAG_CONTAINER_FORMAT, "Matroska", NULL); GST_DEBUG_OBJECT (demux, "Sending global_tags %p : %" GST_PTR_FORMAT, -- 2.7.4