From 71aa45187042dfd49b5ccbdc93c0b48279c167c7 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 22 Jun 2023 23:19:05 -0400 Subject: [PATCH] ges: discoverer-manager: Allow recursing discovery When using deeply nested timelines with the `ges:` protocol the formatters ends up trying to do discovery from the same thread current discovery happens, leading to infinite freeze as GstDiscoverer can't run several discoveries at the same time. By ensuring that when calling `gst_discoverer_discover_uri_async` no `GstDiscoverer` is set as "thread discoverer" we know that another discoverer will be created if discovery recurses, effectively removing the freeze. Part-of: --- .../gst-editing-services/ges/ges-discoverer-manager.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-editing-services/ges/ges-discoverer-manager.c b/subprojects/gst-editing-services/ges/ges-discoverer-manager.c index 8305a32c44..1a67d2dbfd 100644 --- a/subprojects/gst-editing-services/ges/ges-discoverer-manager.c +++ b/subprojects/gst-editing-services/ges/ges-discoverer-manager.c @@ -321,11 +321,12 @@ ges_discoverer_manager_get_discoverer (GESDiscovererManager * self) ret = g_hash_table_lookup (self->discoverers, g_thread_self ()); if (!ret) { ret = create_discoverer (self); - g_hash_table_insert (self->discoverers, g_thread_self (), ret); + } else { + g_hash_table_steal (self->discoverers, g_thread_self ()); } g_mutex_unlock (&self->lock); - return gst_object_ref (ret); + return ret; } gboolean @@ -339,7 +340,11 @@ ges_discoverer_manager_start_discovery (GESDiscovererManager * self, discoverer = ges_discoverer_manager_get_discoverer (self); gboolean res = gst_discoverer_discover_uri_async (discoverer, uri); - gst_object_unref (discoverer); + + g_mutex_lock (&self->lock); + g_hash_table_insert (self->discoverers, g_thread_self (), discoverer); + g_mutex_unlock (&self->lock); + return res; }