From a2bb04c899f373d62a310c48d4015c5e00755fbe Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 12 Oct 2023 13:18:44 -0300 Subject: [PATCH] discoverer: Fix accumulating discoverer info when loading from cache With the previous accumualator loading stopped after the first handler, even if it return NULL which is unexpected, instead we want to use the first non-value returned by handlers. Part-of: --- .../gst-libs/gst/pbutils/gstdiscoverer.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c index 1ef00c718e..f913f451c2 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c @@ -219,6 +219,21 @@ static GstDiscovererStreamInfo *_parse_discovery (GVariant * variant, static GstDiscovererInfo *load_serialized_info (GstDiscoverer * dc, gchar * uri); +static gboolean +_gst_discoverer_info_accumulator (GSignalInvocationHint * ihint, + GValue * return_accu, const GValue * handler_return, gpointer dummy) +{ + GstDiscovererInfo *info; + + info = g_value_get_object (handler_return); + GST_DEBUG ("got discoverer info %" GST_PTR_FORMAT, info); + + g_value_set_object (return_accu, info); + + /* stop emission if we have a discoverer info */ + return (info == NULL); +} + static void gst_discoverer_class_init (GstDiscovererClass * klass) { @@ -346,7 +361,7 @@ gst_discoverer_class_init (GstDiscovererClass * klass) gst_discoverer_signals[SIGNAL_LOAD_SERIALIZED_INFO] = g_signal_new ("load-serialized-info", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDiscovererClass, - load_serialize_info), g_signal_accumulator_first_wins, NULL, NULL, + load_serialize_info), _gst_discoverer_info_accumulator, NULL, NULL, GST_TYPE_DISCOVERER_INFO, 1, G_TYPE_STRING); }