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: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/202>
This commit is contained in:
Doug Nazar 2021-04-29 03:07:42 -04:00
parent a8a45b5776
commit 274c8e6b97

View file

@ -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");