main: Add support for deps flag in loading modules

- support loading modules dependent on wireplumber settings in JSON
  config.
- load the settings module before parsing wireplumber.components,
  so that dependencies can be fetched during parsing.
- access lua scripts are switched to JSON based config and lua configs
  are removed.
This commit is contained in:
Ashok Sidipotu
2022-04-27 18:18:03 +05:30
committed by Julian Bouzas
parent a5d62b7bbd
commit a4f16a98f0
9 changed files with 86 additions and 104 deletions

View File

@@ -1476,12 +1476,12 @@ static gboolean
get_boolean (lua_State *L)
{
const char *setting = luaL_checkstring (L, 1);
const char *metadata_name = NULL;
const char *m = NULL;
if (lua_type (L, 2) == LUA_TSTRING)
metadata_name = luaL_checkstring (L, 2);
m = luaL_checkstring (L, 2);
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), metadata_name);
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), m);
if (s)
{
@@ -1497,14 +1497,14 @@ static gboolean
apply_rule (lua_State *L)
{
const char *r = luaL_checkstring (L, 1);
const char *metadata_name = NULL;
const char *m = NULL;
g_autoptr (WpProperties) cp = wplua_table_to_properties (L, 2);
g_autoptr (WpProperties) ap = wp_properties_new_empty ();
if (lua_type (L, -1) == LUA_TSTRING)
metadata_name = luaL_checkstring (L, -1);
m = luaL_checkstring (L, -1);
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), metadata_name);
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), m);
if (s)
{

View File

@@ -56,6 +56,7 @@ wp_lua_scripting_package_searcher (lua_State *L)
lua_pushcfunction (L, wp_lua_scripting_package_loader);
/* 2. loader data (param to 1) */
wp_debug ("Executing script %s", script);
if (!wplua_load_path (L, script, &error)) {
lua_pop (L, 1);
lua_pushstring (L, error->message);
@@ -206,6 +207,7 @@ wp_lua_scripting_plugin_load (WpComponentLoader * cl, const gchar * component,
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);
g_ptr_array_add (self->scripts, g_steal_pointer (&script));
}
return TRUE;