From a91b51c9b7cc7adabfa0cf0153a2e25efd0b6b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 31 May 2014 17:35:52 +0200 Subject: [PATCH] typefind: Keep still meaningfull pending events on FLUSH_STOP Only EOS and segment should be deleted in that case. https://bugzilla.gnome.org/show_bug.cgi?id=709868 --- plugins/elements/gsttypefindelement.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index 1531fc17d6..400c370fb8 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -642,15 +642,27 @@ gst_type_find_element_sink_event (GstPad * pad, GstObject * parent, res = gst_pad_push_event (typefind->src, event); break; } - case GST_EVENT_FLUSH_STOP: + case GST_EVENT_FLUSH_STOP:{ + GList *l; + GST_OBJECT_LOCK (typefind); - g_list_foreach (typefind->cached_events, - (GFunc) gst_mini_object_unref, NULL); + + for (l = typefind->cached_events; l; l = l->next) { + if (!GST_EVENT_IS_STICKY (l->data) || + GST_EVENT_TYPE (l->data) == GST_EVENT_SEGMENT || + GST_EVENT_TYPE (l->data) == GST_EVENT_EOS) { + gst_event_unref (l->data); + } else { + gst_pad_store_sticky_event (typefind->src, l->data); + } + } + g_list_free (typefind->cached_events); typefind->cached_events = NULL; gst_adapter_clear (typefind->adapter); GST_OBJECT_UNLOCK (typefind); /* fall through */ + } case GST_EVENT_FLUSH_START: res = gst_pad_push_event (typefind->src, event); break;