From e730ce71dc72df6d380d53c1a65aacb0c0c134b6 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 18 Jan 2011 00:08:32 +0530 Subject: [PATCH] discoverer: Make sure we call _stop() before being freed This ensures that everything is properly cleaned up before the GstDiscoverer object is freed. Specifically, it makes sure that we've removed the async timeout callback before freeing the object to avoid a potential crash later on. https://bugzilla.gnome.org/show_bug.cgi?id=639755 --- gst-libs/gst/pbutils/gstdiscoverer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer.c b/gst-libs/gst/pbutils/gstdiscoverer.c index bc99f43..ab32b91 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/gst-libs/gst/pbutils/gstdiscoverer.c @@ -304,7 +304,8 @@ discoverer_reset (GstDiscoverer * dc) dc->priv->pending_uris = NULL; } - gst_element_set_state ((GstElement *) dc->priv->pipeline, GST_STATE_NULL); + if (dc->priv->pipeline) + gst_element_set_state ((GstElement *) dc->priv->pipeline, GST_STATE_NULL); } static void @@ -325,6 +326,8 @@ gst_discoverer_dispose (GObject * obj) dc->priv->bus = NULL; } + gst_discoverer_stop (dc); + if (dc->priv->lock) { g_mutex_free (dc->priv->lock); dc->priv->lock = NULL; @@ -1271,9 +1274,11 @@ gst_discoverer_stop (GstDiscoverer * discoverer) /* We prevent any further processing by setting the bus to * flushing and setting the pipeline to READY. * _reset() will take care of the rest of the cleanup */ - gst_bus_set_flushing (discoverer->priv->bus, TRUE); - gst_element_set_state ((GstElement *) discoverer->priv->pipeline, - GST_STATE_READY); + if (discoverer->priv->bus) + gst_bus_set_flushing (discoverer->priv->bus, TRUE); + if (discoverer->priv->pipeline) + gst_element_set_state ((GstElement *) discoverer->priv->pipeline, + GST_STATE_READY); } discoverer->priv->running = FALSE; DISCO_UNLOCK (discoverer); -- 2.7.4