From 85900fba646f83e921d6d946397b1e352c6cce78 Mon Sep 17 00:00:00 2001 From: Ashok Sidipotu Date: Thu, 27 Oct 2022 15:08:22 +0530 Subject: [PATCH] m-lua-scripting: support dangling components - Dangling components are those not present in the json config files but present in the wireplumber lookup folders. --- modules/module-lua-scripting/module.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/module-lua-scripting/module.c b/modules/module-lua-scripting/module.c index c1554458..61aaaa18 100644 --- a/modules/module-lua-scripting/module.c +++ b/modules/module-lua-scripting/module.c @@ -182,32 +182,42 @@ wp_lua_scripting_plugin_load (WpComponentLoader * cl, const gchar * component, /* interpret component as a script */ if (!g_strcmp0 (type, "script/lua")) { - g_autofree gchar *filename = NULL; + g_autofree gchar *filepath = NULL; g_autofree gchar *pluginname = NULL; g_autoptr (WpPlugin) script = NULL; - filename = find_script (component, core); - if (!filename) { + if (g_file_test (component, G_FILE_TEST_EXISTS)) { + /* dangling components come with full path */ + g_autofree gchar *filename = g_path_get_basename (component); + filepath = g_strdup (component); + pluginname = g_strdup_printf ("script:%s", filename); + } + else { + filepath = find_script (component, core); + pluginname = g_strdup_printf ("script:%s", component); + } + + if (!filepath) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Could not locate script '%s'", component); return FALSE; } - pluginname = g_strdup_printf ("script:%s", component); - script = g_object_new (WP_TYPE_LUA_SCRIPT, "core", core, "name", pluginname, - "filename", filename, + "filename", filepath, "arguments", args, NULL); if (self->L) { + wp_debug_object (core, "loading script(%s) plugin name(%s)", + filepath, pluginname); g_object_set (script, "lua-engine", self->L, NULL); wp_plugin_register (g_steal_pointer (&script)); } else { /* keep in a list and delay registering until the plugin is enabled */ - wp_debug ("queing script %s", filename); + wp_debug ("queuing script %s", filepath); g_ptr_array_add (self->scripts, g_steal_pointer (&script)); } return TRUE;