From 4c2f91d69e82917b3c1744bac87b8f120ec3f97f Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 15 Nov 2017 10:51:33 +0100 Subject: [PATCH] discoverer: Don't remove element when switching to PLAYING There is a race going on somewhere when we attempt to remove elements *while* the parent container is switching to PLAYING. In order to avoid this issue with discoverer, make sure we never remove elements while switching to PLAYING. --- gst-libs/gst/pbutils/gstdiscoverer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer.c b/gst-libs/gst/pbutils/gstdiscoverer.c index 576f0e8..0993616 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/gst-libs/gst/pbutils/gstdiscoverer.c @@ -743,7 +743,6 @@ uridecodebin_pad_removed_cb (GstElement * uridecodebin, GstPad * pad, gst_pad_remove_probe (pad, ps->probe_id); dc->priv->streams = g_list_delete_link (dc->priv->streams, tmp); - DISCO_UNLOCK (dc); gst_element_set_state (ps->sink, GST_STATE_NULL); gst_element_set_state (ps->queue, GST_STATE_NULL); @@ -756,6 +755,7 @@ uridecodebin_pad_removed_cb (GstElement * uridecodebin, GstPad * pad, /* references removed here */ gst_bin_remove_many (dc->priv->pipeline, ps->sink, ps->queue, NULL); + DISCO_UNLOCK (dc); if (ps->tags) { gst_tag_list_unref (ps->tags); } @@ -1340,7 +1340,10 @@ discoverer_collect (GstDiscoverer * dc) * completely bogus values. We need some API extensions to solve this * better. */ GST_INFO ("No duration yet, try a bit harder.."); + /* Make sure we don't add/remove elements while switching to PLAYING itself */ + DISCO_LOCK (dc); sret = gst_element_set_state (pipeline, GST_STATE_PLAYING); + DISCO_UNLOCK (dc); if (sret != GST_STATE_CHANGE_FAILURE) { int i; -- 2.7.4