ges: discoverer-manager: Fix race leading to assertion when stopping

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3757

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7421>
This commit is contained in:
Thibault Saunier 2024-02-16 12:48:59 -03:00 committed by GStreamer Marge Bot
parent 2d989058a7
commit 97e5749bfc

View file

@ -1,6 +1,8 @@
#include "ges-internal.h"
#include "ges-discoverer-manager.h"
G_LOCK_DEFINE_STATIC (singleton_lock);
static GESDiscovererManager *self = NULL;
typedef struct
{
@ -17,7 +19,7 @@ static void
ges_discoverer_data_free (GESDiscovererData * data)
{
GST_LOG ("Freeing discoverer %" GST_PTR_FORMAT, data->discoverer);
g_assert (data->n_uri == 0);
g_assert (data->n_uri == 0 || !self);
gst_discoverer_stop (data->discoverer);
g_signal_handler_disconnect (data->discoverer, data->load_serialized_info_id);
g_signal_handler_disconnect (data->discoverer, data->source_setup_id);
@ -73,8 +75,6 @@ enum
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static guint signals[N_SIGNALS] = { 0, };
G_LOCK_DEFINE_STATIC (singleton_lock);
static GESDiscovererManager *self = NULL;
static void
ges_discoverer_manager_get_property (GObject * object,
@ -485,6 +485,10 @@ void
ges_discoverer_manager_cleanup (void)
{
G_LOCK (singleton_lock);
gst_clear_object (&self);
GESDiscovererManager *manager = self;
self = NULL;
if (manager)
gst_object_unref (manager);
G_UNLOCK (singleton_lock);
}