From 8752d081133e5fbb05e4566dda4bbe251fe27107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 19 Jan 2025 15:39:30 +0100 Subject: [PATCH] clapper: enhancers-loader: Fix default enhancers dir on Win32 --- src/lib/clapper/clapper-enhancers-loader.c | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lib/clapper/clapper-enhancers-loader.c b/src/lib/clapper/clapper-enhancers-loader.c index 286a77ec..6c7a26f4 100644 --- a/src/lib/clapper/clapper-enhancers-loader.c +++ b/src/lib/clapper/clapper-enhancers-loader.c @@ -22,6 +22,11 @@ #include #include +#ifdef G_OS_WIN32 +#include +static HMODULE _enhancers_dll_handle = NULL; +#endif + #include "clapper-enhancers-loader-private.h" #define ENHANCER_INTERFACES "X-Interfaces" @@ -44,13 +49,29 @@ void clapper_enhancers_loader_initialize (void) { const gchar *enhancers_path; - gchar **dir_paths; + gchar **dir_paths, *custom_path = NULL; guint i; GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperenhancersloader", 0, "Clapper Enhancer Loader"); enhancers_path = g_getenv ("CLAPPER_ENHANCERS_PATH"); + +#ifdef G_OS_WIN32 + if (!enhancers_path || *enhancers_path == '\0') { + gchar *win_base_dir; + + win_base_dir = g_win32_get_package_installation_directory_of_module ( + _enhancers_dll_handle); + /* FIXME: Avoid hardcoded major version */ + custom_path = g_build_filename (win_base_dir, + "lib", "clapper-0.0", "enhancers", NULL); + enhancers_path = custom_path; // assign temporarily + + g_free (win_base_dir); + } +#endif + if (!enhancers_path || *enhancers_path == '\0') enhancers_path = CLAPPER_ENHANCERS_PATH; @@ -83,6 +104,8 @@ clapper_enhancers_loader_initialize (void) GST_INFO ("Clapper enhancers initialized, found: %u", n_items); } + + g_free (custom_path); } static inline gboolean