From 83f8ee1d41a238b2fc54c127eee8dee33390d08f Mon Sep 17 00:00:00 2001 From: MathieuDuponchelle Date: Sat, 14 Sep 2013 03:27:09 +0200 Subject: [PATCH] videomixer2: Merge tag events to send them in collected. Otherwise there were race conditions where we would send tags on a flushing srcpad. We have a test for that in GES, but this should be tested systematically with harness in the future as I believe it is useful for exactly that kind of cases. https://bugzilla.gnome.org/show_bug.cgi?id=708165 --- gst/videomixer/videomixer2.c | 28 ++++++++++++++++++++++++++++ gst/videomixer/videomixer2.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c index fbcab60254..eaafe2cede 100644 --- a/gst/videomixer/videomixer2.c +++ b/gst/videomixer/videomixer2.c @@ -1238,6 +1238,11 @@ gst_videomixer2_collected (GstCollectPads * pads, GstVideoMixer2 * mix) } } + if (G_UNLIKELY (mix->pending_tags)) { + gst_pad_push_event (mix->srcpad, gst_event_new_tag (mix->pending_tags)); + mix->pending_tags = NULL; + } + if (mix->segment.stop != -1) output_end_time = MIN (output_end_time, mix->segment.stop); @@ -1922,6 +1927,10 @@ gst_videomixer2_sink_event (GstCollectPads * pads, GstCollectData * cdata, g_atomic_int_set (&mix->flush_stop_pending, FALSE); ret = gst_collect_pads_event_default (pads, cdata, event, discard); event = NULL; + if (mix->pending_tags) { + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = NULL; + } break; case GST_EVENT_FLUSH_STOP: mix->newseg_pending = TRUE; @@ -1945,6 +1954,19 @@ gst_videomixer2_sink_event (GstCollectPads * pads, GstCollectData * cdata, mix->ts_offset = 0; mix->nframes = 0; break; + case GST_EVENT_TAG: + { + /* collect tags here so we can push them out when we collect data */ + GstTagList *tags; + + gst_event_parse_tag (event, &tags); + tags = gst_tag_list_merge (mix->pending_tags, tags, GST_TAG_MERGE_APPEND); + if (mix->pending_tags) + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = tags; + event = NULL; + break; + } default: break; } @@ -2166,6 +2188,11 @@ gst_videomixer2_dispose (GObject * o) videomixer_videoconvert_convert_free (mixpad->convert); } + if (mix->pending_tags) { + gst_tag_list_unref (mix->pending_tags); + mix->pending_tags = NULL; + } + gst_caps_replace (&mix->current_caps, NULL); } @@ -2295,6 +2322,7 @@ gst_videomixer2_init (GstVideoMixer2 * mix) mix->collect = gst_collect_pads_new (); mix->background = DEFAULT_BACKGROUND; mix->current_caps = NULL; + mix->pending_tags = NULL; gst_collect_pads_set_function (mix->collect, (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_videomixer2_collected), diff --git a/gst/videomixer/videomixer2.h b/gst/videomixer/videomixer2.h index 4a0b744eb9..b247ea8c23 100644 --- a/gst/videomixer/videomixer2.h +++ b/gst/videomixer/videomixer2.h @@ -120,6 +120,8 @@ struct _GstVideoMixer2 FillColorFunction fill_color; gboolean send_stream_start; + + GstTagList *pending_tags; }; struct _GstVideoMixer2Class