Skip to content

Commit

Permalink
clapper: Fix importing enhancers with extra path
Browse files Browse the repository at this point in the history
We cannot use "goto" here, like it was before, as we would fall into an endless loop.
  • Loading branch information
Rafostar committed Jan 20, 2025
1 parent e9377f0 commit 80285fb
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/lib/clapper/clapper-enhancers-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static PeasEngine *_engine = NULL;
static GMutex load_lock;

static inline void
_import_enhancers (const gchar *enhancers_path)
{
gchar **dir_paths = g_strsplit (enhancers_path, G_SEARCHPATH_SEPARATOR_S, 0);
guint i;

for (i = 0; dir_paths[i]; ++i)
peas_engine_add_search_path (_engine, dir_paths[i], NULL);

g_strfreev (dir_paths);
}

/*
* clapper_enhancers_loader_initialize:
*
Expand All @@ -49,8 +61,7 @@ void
clapper_enhancers_loader_initialize (void)
{
const gchar *enhancers_path;
gchar **dir_paths, *custom_path = NULL;
guint i;
gchar *custom_path = NULL;

GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperenhancersloader", 0,
"Clapper Enhancer Loader");
Expand Down Expand Up @@ -84,22 +95,18 @@ clapper_enhancers_loader_initialize (void)
peas_engine_enable_loader (_engine, "python");
peas_engine_enable_loader (_engine, "gjs");

load_enhancers:
dir_paths = g_strsplit (enhancers_path, G_SEARCHPATH_SEPARATOR_S, 0);

for (i = 0; dir_paths[i]; ++i)
peas_engine_add_search_path (_engine, dir_paths[i], NULL);

g_strfreev (dir_paths);
_import_enhancers (enhancers_path);

/* Support loading additional enhancers from non-default directory */
enhancers_path = g_getenv ("CLAPPER_ENHANCERS_EXTRA_PATH");
if (enhancers_path && *enhancers_path != '\0')
goto load_enhancers;
if (enhancers_path && *enhancers_path != '\0') {
GST_INFO ("Enhancers extra path: \"%s\"", enhancers_path);
_import_enhancers (enhancers_path);
}

if (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >= GST_LEVEL_INFO) {
GListModel *list = (GListModel *) _engine;
guint n_items = g_list_model_get_n_items (list);
guint i, n_items = g_list_model_get_n_items (list);

for (i = 0; i < n_items; ++i) {
PeasPluginInfo *info = (PeasPluginInfo *) g_list_model_get_item (list, i);
Expand Down

0 comments on commit 80285fb

Please sign in to comment.