From 27a2fa73bce41f9c748e46a919f057cd84c17604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 26 Nov 2024 15:32:56 +0200 Subject: [PATCH] discoverer: Move cache file tracking from GstDiscovererInfo into GstDiscoverer It's only used temporarily during discovery and makes no sense as part of the resulting info. Part-of: --- .../gst/pbutils/gstdiscoverer-types.c | 2 -- .../gst-libs/gst/pbutils/gstdiscoverer.c | 23 +++++++++++++------ .../gst-libs/gst/pbutils/pbutils-private.h | 3 --- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer-types.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer-types.c index 46b6ee3b51..561be982e5 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer-types.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer-types.c @@ -393,8 +393,6 @@ gst_discoverer_info_finalize (GObject * object) if (info->toc) gst_toc_unref (info->toc); - g_free (info->cachefile); - g_ptr_array_unref (info->missing_elements_details); G_OBJECT_CLASS (gst_discoverer_info_parent_class)->finalize (object); 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 3af719aae4..fa10478d2b 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/gstdiscoverer.c @@ -97,6 +97,8 @@ struct _GstDiscovererPrivate gint current_info_stream_count; GError *current_error; GstStructure *current_topology; + gchar *current_cachefile; + gboolean current_info_from_cache; GstTagList *all_tags; GstTagList *global_tags; @@ -1369,12 +1371,12 @@ static void serialize_info_if_required (GstDiscoverer * dc, GstDiscovererInfo * info) { - if (dc->priv->use_cache && info->cachefile + if (dc->priv->use_cache && dc->priv->current_cachefile && info->result == GST_DISCOVERER_OK) { GVariant *variant = gst_discoverer_info_to_variant (info, GST_DISCOVERER_SERIALIZE_ALL); - g_file_set_contents (info->cachefile, + g_file_set_contents (dc->priv->current_cachefile, g_variant_get_data (variant), g_variant_get_size (variant), NULL); g_variant_unref (variant); } @@ -1392,6 +1394,9 @@ emit_discovered (GstDiscoverer * dc) gst_discoverer_info_unref (dc->priv->current_info); dc->priv->current_info = NULL; dc->priv->current_info_stream_count = 0; + g_free (dc->priv->current_cachefile); + dc->priv->current_cachefile = NULL; + dc->priv->current_info_from_cache = FALSE; } static gboolean @@ -1419,7 +1424,7 @@ discoverer_collect (GstDiscoverer * dc) } if (dc->priv->use_cache && dc->priv->current_info - && dc->priv->current_info->from_cache) { + && dc->priv->current_info_from_cache) { GST_DEBUG_OBJECT (dc, "Nothing to collect as the info was built from" " the cache"); return; @@ -1852,13 +1857,14 @@ _get_info_from_cachefile (GstDiscoverer * dc, gchar * cachefile) g_variant_unref (variant); if (info) { - info->cachefile = cachefile; - info->from_cache = (gpointer) 0x01; + dc->priv->current_cachefile = cachefile; + dc->priv->current_info_from_cache = TRUE; } else { g_free (cachefile); } - GST_INFO_OBJECT (dc, "Got info from cache: %p %s", info, info->cachefile); + GST_INFO_OBJECT (dc, "Got info from cache: %p %s", info, + dc->priv->current_cachefile); g_free (data); return info; @@ -1915,7 +1921,7 @@ _setup_locked (GstDiscoverer * dc) (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL); dc->priv->current_info_stream_count = 0; if (dc->priv->use_cache) - dc->priv->current_info->cachefile = _serialized_info_get_path (dc, uri); + dc->priv->current_cachefile = _serialized_info_get_path (dc, uri); dc->priv->current_info->uri = uri; /* set uri on uridecodebin */ @@ -1983,6 +1989,9 @@ discoverer_cleanup (GstDiscoverer * dc) dc->priv->current_info = NULL; dc->priv->current_info_stream_count = 0; + g_free (dc->priv->current_cachefile); + dc->priv->current_cachefile = NULL; + dc->priv->current_info_from_cache = FALSE; if (dc->priv->all_tags) { gst_tag_list_unref (dc->priv->all_tags); diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils-private.h b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils-private.h index 42b1b5530f..51ff8623ad 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils-private.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/pbutils-private.h @@ -97,9 +97,6 @@ struct _GstDiscovererInfo { gboolean live; gboolean seekable; GPtrArray *missing_elements_details; - - gchar *cachefile; - gpointer from_cache; }; /* missing-plugins.c */