From d4690089050493b839375849e7cbd6ba63faf65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 25 May 2026 18:40:23 +0200 Subject: [PATCH 1/5] clapper: gst: Allow extractables to specify whether they use cache Some extractables might never use caching. We do not know that since we do not know what they do in their code, but if we knew we could skip local file IO before extract. Solve this by allowing them to explicitly specify no cache support in their plugin config file using "X-Use-Cache=false" option. --- .../clapper/extractable-enhancers.md | 6 ++- .../clapper/gst/clapper-enhancer-director.c | 47 +++++++++++++------ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/doc/reference/clapper/extractable-enhancers.md b/doc/reference/clapper/extractable-enhancers.md index 5344a3149..f1f8f2642 100644 --- a/doc/reference/clapper/extractable-enhancers.md +++ b/doc/reference/clapper/extractable-enhancers.md @@ -16,8 +16,10 @@ For the basics about writing enhancers see [Clapper Enhancers](clapper-enhancers ### Requirements -Additional fields for `.plugin` info file: `X-Schemes` and `X-Hosts`. The former one should -hold the `;` separated list of supported URI schemes, while the latter is for hostnames. +Additional fields for `.plugin` info file: `X-Schemes`, `X-Hosts`, `X-Use-Cache`. +The former one is required and should hold the `;` separated list of supported URI schemes, +while the second is for hostnames and the last one is also optional (set to `false` in order +skip trying to restore harvested data from cache if enhancer never caches any data). Example: diff --git a/src/lib/clapper/gst/clapper-enhancer-director.c b/src/lib/clapper/gst/clapper-enhancer-director.c index 1f71cd316..8f2f36d24 100644 --- a/src/lib/clapper/gst/clapper-enhancer-director.c +++ b/src/lib/clapper/gst/clapper-enhancer-director.c @@ -89,25 +89,39 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) ClapperEnhancerProxy *proxy = CLAPPER_ENHANCER_PROXY_CAST (el->data); ClapperExtractable *extractable = NULL; GstStructure *config; - - /* Ensures that we do not start extraction of the same URI concurrently. - * If given job is already running, blocks here until finished. - * Afterwards we try to read extracted data from cache. */ - clapper_enhancer_proxy_await_job_start (proxy, job_id); - - /* Cancelled during waiting for usage access */ - if (g_cancellable_is_cancelled (data->cancellable)) { - clapper_enhancer_proxy_remove_job (proxy, job_id); - break; + const gchar *extra_data; + gboolean cache_disabled; + + /* Skip cache IO if extractable explicitly says + * it is not supported in it (enabled by default) */ + extra_data = clapper_enhancer_proxy_get_extra_data (proxy, "X-Use-Cache"); + cache_disabled = (extra_data && g_ascii_strcasecmp (extra_data, "false") == 0); + + if (!cache_disabled) { + /* Ensures that we do not start extraction of the same URI concurrently. + * If given job is already running, blocks here until finished. + * Afterwards we try to read extracted data from cache. */ + clapper_enhancer_proxy_await_job_start (proxy, job_id); + + /* Cancelled during waiting for usage access */ + if (g_cancellable_is_cancelled (data->cancellable)) { + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; + } } harvest = clapper_harvest_new (); // fresh harvest for each iteration config = clapper_enhancer_proxy_make_current_config (proxy); - if ((success = clapper_harvest_fill_from_cache (harvest, proxy, config, data->uri)) - || g_cancellable_is_cancelled (data->cancellable)) { // Check before extract + success = (!cache_disabled + && clapper_harvest_fill_from_cache (harvest, proxy, config, data->uri)); + + /* Skip extraction if restored from cache or cancelled */ + if (success || g_cancellable_is_cancelled (data->cancellable)) { gst_clear_structure (&config); - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; } @@ -131,12 +145,15 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) clapper_harvest_export_to_cache (harvest, proxy, config, data->uri); } gst_clear_structure (&config); - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); + break; } } - clapper_enhancer_proxy_remove_job (proxy, job_id); + if (!cache_disabled) + clapper_enhancer_proxy_remove_job (proxy, job_id); /* Cleanup to try again with next enhancer */ g_clear_object (&harvest); From b2489ce3a5e44e4b8b6a0bff30f77063c10a2804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 26 May 2026 08:18:01 +0200 Subject: [PATCH 2/5] clapper: gst: Fix crash when extraction or parsing is cancelled early Avoid returning without error being set. This caused crashes when app tried to print message of that error. --- src/lib/clapper/gst/clapper-enhancer-director.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/clapper/gst/clapper-enhancer-director.c b/src/lib/clapper/gst/clapper-enhancer-director.c index 8f2f36d24..4665c34cf 100644 --- a/src/lib/clapper/gst/clapper-enhancer-director.c +++ b/src/lib/clapper/gst/clapper-enhancer-director.c @@ -76,7 +76,7 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) /* Cancelled during thread switching */ if (g_cancellable_is_cancelled (data->cancellable)) - return NULL; + goto finish; uri_str = g_uri_to_string (data->uri); job_id = g_str_hash (uri_str); @@ -164,6 +164,7 @@ clapper_enhancer_director_extract_in_thread (ClapperEnhancerDirectorData *data) if (g_cancellable_is_cancelled (data->cancellable)) success = FALSE; +finish: if (!success) { gst_clear_object (&harvest); @@ -197,7 +198,7 @@ clapper_enhancer_director_parse_in_thread (ClapperEnhancerDirectorData *data) /* Cancelled during thread switching */ if (g_cancellable_is_cancelled (data->cancellable)) - return NULL; + goto finish; GST_DEBUG_OBJECT (self, "Enhancer proxies for buffer: %u", g_list_length (data->filtered_proxies)); @@ -259,6 +260,7 @@ clapper_enhancer_director_parse_in_thread (ClapperEnhancerDirectorData *data) if (g_cancellable_is_cancelled (data->cancellable)) success = FALSE; +finish: if (!success) { g_clear_object (&playlist); From b1b71b0dfa5495092bc4f0d6ed331ae88e80f438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 26 May 2026 08:23:11 +0200 Subject: [PATCH 3/5] clapper: gst: Fix crash when URI handler was not found Debug message uses GST_OBJECT_NAME on a returned element pointer. In the scenario when compatible element for URI could not be found this causes crash as that macro is not safe to run on a NULL. --- src/lib/clapper/gst/clapper-uri-base-demux.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/clapper/gst/clapper-uri-base-demux.c b/src/lib/clapper/gst/clapper-uri-base-demux.c index b6baf2f18..dfd50b52b 100644 --- a/src/lib/clapper/gst/clapper-uri-base-demux.c +++ b/src/lib/clapper/gst/clapper-uri-base-demux.c @@ -183,9 +183,6 @@ _make_handler_for_uri (ClapperUriBaseDemux *self, const gchar *uri, const gchar gst_plugin_feature_list_free (factories); - GST_DEBUG_OBJECT (self, "Created URI handler: %s", - GST_OBJECT_NAME (element)); - return element; } @@ -238,9 +235,11 @@ clapper_uri_base_demux_set_uri (ClapperUriBaseDemux *self, const gchar *uri, con priv->uri_handler = _make_handler_for_uri (self, uri, blacklisted_el); - if (G_UNLIKELY (!priv->uri_handler)) { + if (G_LIKELY (priv->uri_handler != NULL)) { + GST_DEBUG_OBJECT (self, "Created URI handler: %s", + GST_OBJECT_NAME (priv->uri_handler)); + } else { GST_ERROR_OBJECT (self, "Could not create URI handler element"); - GST_ELEMENT_ERROR (self, CORE, MISSING_PLUGIN, ("Missing plugin to handle URI: %s", uri), (NULL)); From ead6829a443545a6524a25277f37354b62f8dc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 26 May 2026 19:41:17 +0200 Subject: [PATCH 4/5] clapper-app: Use "numeric" style class for queue titles Makes spacing even which looks much better when an episodic series is put in playback queue. --- src/bin/clapper-app/ui/clapper-app-headerbar.ui | 1 + src/bin/clapper-app/ui/clapper-app-queue-list-item.ui | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bin/clapper-app/ui/clapper-app-headerbar.ui b/src/bin/clapper-app/ui/clapper-app-headerbar.ui index 5c15f04e2..c4186d3f5 100644 --- a/src/bin/clapper-app/ui/clapper-app-headerbar.ui +++ b/src/bin/clapper-app/ui/clapper-app-headerbar.ui @@ -86,6 +86,7 @@ true diff --git a/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui b/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui index cc1d8c7e5..298516e69 100644 --- a/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui +++ b/src/bin/clapper-app/ui/clapper-app-queue-list-item.ui @@ -30,6 +30,7 @@ From bee640001c24043b21699ad3bc7289026a101664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 26 May 2026 19:49:19 +0200 Subject: [PATCH 5/5] clapper-gtk: Use "numeric" style class for title header For consistency with how elsewhere this text is displayed --- src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui b/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui index fae5d27b4..402759ec4 100644 --- a/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui +++ b/src/lib/clapper-gtk/ui/clapper-gtk-title-header.ui @@ -15,6 +15,7 @@ center