From d5acbdd87c6402d8bc7f72ddc39f40918bc8554b Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Wed, 11 Sep 2019 13:09:22 +0300 Subject: [PATCH] daemon config: add the ability to register spa libraries from the config file --- src/main.c | 27 ++++++++++++++++++++++++++- src/meson.build | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index b50a3ffc..4e5b5ce9 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ #include <wp/wp.h> #include <gio/gio.h> #include <glib-unix.h> +#include <pipewire/pipewire.h> static GOptionEntry entries[] = { @@ -98,7 +99,7 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream, gchar buffer[4096]; gssize bytes_read; gchar *cur, *linestart, *saveptr; - gchar *cmd, *abi, *module, *props; + gchar *cmd; gint lineno = 1, block_lines = 1, in_block = 0; gboolean eof = FALSE; GVariant *properties; @@ -148,6 +149,8 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream, if (!cmd || cmd[0] == '#') { /* empty line or comment, skip */ } else if (!g_strcmp0 (cmd, "load-module")) { + gchar *abi, *module, *props; + abi = strtok_r (NULL, " ", &saveptr); module = strtok_r (NULL, " ", &saveptr); @@ -181,6 +184,28 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream, if (!wp_module_load (d->core, abi, module, properties, error)) { return FALSE; } + } else if (!g_strcmp0 (cmd, "add-spa-lib")) { + gchar *regex, *lib; + gint ret; + + regex = strtok_r (NULL, " ", &saveptr); + lib = strtok_r (NULL, " ", &saveptr); + + if (!regex || !lib || + (regex && regex[0] == '{') || (lib && lib[0] == '{')) + { + g_set_error (error, WP_DOMAIN_DAEMON, WP_CODE_INVALID_ARGUMENT, + "expected REGEX and LIB at line %i", lineno); + return FALSE; + } + + ret = pw_core_add_spa_lib (wp_core_get_pw_core (d->core), regex, lib); + if (ret < 0) { + g_set_error (error, WP_DOMAIN_DAEMON, WP_CODE_OPERATION_FAILED, + "failed to add spa lib ('%s' on '%s'): %s", regex, lib, + g_strerror (-ret)); + return FALSE; + } } else { g_set_error (error, WP_DOMAIN_DAEMON, WP_CODE_INVALID_ARGUMENT, "unknown command '%s' at line %i", cmd, lineno); diff --git a/src/meson.build b/src/meson.build index f7a4628b..4e9ecfbd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -16,5 +16,5 @@ executable('wireplumber', '-DWIREPLUMBER_DEFAULT_CONFIG_FILE="@0@"'.format(wireplumber_config_file), ], install: true, - dependencies : [gobject_dep, gio_dep, wp_dep], + dependencies : [gobject_dep, gio_dep, wp_dep, pipewire_dep], ) -- GitLab