mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-04 05:00:26 +01:00
wp: support loading optional modules
-some modules will not be available during runtime, due to external dependencies. -these modules can now be marked optional. -loading of these optional modules will be attempted and if they are not available, wp will recover and will not be terminated.
This commit is contained in:
parent
27a6970de5
commit
784c405c31
3 changed files with 26 additions and 4 deletions
|
|
@ -63,10 +63,23 @@ load_components (lua_State *L, WpCore * core, GError ** error)
|
|||
args = wplua_lua_to_gvariant (L, -1);
|
||||
}
|
||||
|
||||
wp_debug ("load component: %s (%s)", component, type);
|
||||
gboolean optional = FALSE;
|
||||
if (lua_getfield (L, table, "optional") == LUA_TBOOLEAN) {
|
||||
optional = lua_toboolean (L, -1);
|
||||
}
|
||||
|
||||
if (!wp_core_load_component (core, component, type, args, error))
|
||||
return FALSE;
|
||||
wp_debug ("load component: %s (%s) optional(%s)",
|
||||
component, type, (optional ? "true" : "false"));
|
||||
|
||||
g_autoptr (GError) load_error = NULL;
|
||||
if (!wp_core_load_component (core, component, type, args, &load_error)) {
|
||||
if (!optional) {
|
||||
g_propagate_error (error, g_steal_pointer (&load_error));
|
||||
return FALSE;
|
||||
} else {
|
||||
wp_message ("%s", load_error->message);
|
||||
}
|
||||
}
|
||||
|
||||
/* clear the stack up to the key */
|
||||
lua_settop (L, key);
|
||||
|
|
|
|||
|
|
@ -8,5 +8,5 @@ function bluez_monitor.enable()
|
|||
rules = bluez_monitor.rules,
|
||||
})
|
||||
|
||||
load_module("logind")
|
||||
load_optional_module("logind")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
components = {}
|
||||
|
||||
function load_module(m, a)
|
||||
assert(type(m) == "string", "module name is mandatory, bail out");
|
||||
if not components[m] then
|
||||
components[m] = { "libwireplumber-module-" .. m, type = "module", args = a }
|
||||
end
|
||||
end
|
||||
|
||||
function load_optional_module(m, a)
|
||||
assert(type(m) == "string", "module name is mandatory, bail out");
|
||||
if not components[m] then
|
||||
components[m] = { "libwireplumber-module-" .. m, type = "module", args = a, optional = true }
|
||||
end
|
||||
end
|
||||
|
||||
function load_pw_module(m)
|
||||
assert(type(m) == "string", "module name is mandatory, bail out");
|
||||
if not components[m] then
|
||||
components[m] = { "libpipewire-module-" .. m, type = "pw_module" }
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue