From 274c8e6b978f71c4fcd7082dbffaf786167394b7 Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Thu, 29 Apr 2021 03:07:42 -0400 Subject: [PATCH] rtsp-media: Ensure the bus watch is removed during unprepare It's possible for the destruction of the source to be delayed. Instead of relying on the dispose() to remove the bus watch, do it ourselves. Part-of: --- gst/rtsp-server/rtsp-media.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 55d2b31..63f43bc 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -131,7 +131,6 @@ struct _GstRTSPMediaPrivate /* the pipeline for the media */ GstElement *pipeline; GSource *source; - guint id; GstRTSPThread *thread; GList *pending_pipeline_elements; @@ -3811,7 +3810,7 @@ default_prepare (GstRTSPMedia * media, GstRTSPThread * thread) g_source_set_callback (priv->source, (GSourceFunc) bus_message, g_object_ref (media), (GDestroyNotify) watch_destroyed); - priv->id = g_source_attach (priv->source, context); + g_source_attach (priv->source, context); /* add stuff to the bin */ gst_bin_add (GST_BIN (priv->pipeline), priv->rtpbin); @@ -4034,9 +4033,17 @@ finish_unprepare (GstRTSPMedia * media) /* the source has the last ref to the media */ if (priv->source) { + GstBus *bus; + + GST_DEBUG ("removing bus watch"); + bus = gst_pipeline_get_bus (GST_PIPELINE_CAST (priv->pipeline)); + gst_bus_remove_watch (bus); + gst_object_unref (bus); + GST_DEBUG ("destroy source"); g_source_destroy (priv->source); g_source_unref (priv->source); + priv->source = NULL; } if (priv->thread) { GST_DEBUG ("stop thread"); -- 2.7.4