diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-05-31 15:03:56 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-05-31 15:03:56 +0200 |
commit | 89a86db0c4c3decfc8cb48bedecdfdd176c10310 (patch) | |
tree | d5291f491ed049449e4a26a92161b7bf484dfd0b | |
parent | b9d904269514174cd69806b3b9cba0888925430e (diff) |
command: add add-spa-lib command
Add a command to add a factory name regex to library mapping.
-rw-r--r-- | src/examples/video-play.c | 2 | ||||
-rw-r--r-- | src/pipewire/command.c | 42 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/examples/video-play.c b/src/examples/video-play.c index 44f2d6dd..7708ab61 100644 --- a/src/examples/video-play.c +++ b/src/examples/video-play.c @@ -335,7 +335,7 @@ int main(int argc, char *argv[]) * If you plan to autoconnect your stream, you need to provide at least * media, category and role properties * - * Pass your events and a use_data pointer as the last arguments. This + * Pass your events and a user_data pointer as the last arguments. This * will inform you about the stream state. The most important event * you need to listen to is the process event where you need to consume * the data provided to you. diff --git a/src/pipewire/command.c b/src/pipewire/command.c index c47d6e32..8fb82648 100644 --- a/src/pipewire/command.c +++ b/src/pipewire/command.c @@ -38,6 +38,7 @@ /** \cond */ static struct pw_command *parse_command_help(const char *line, char **err); +static struct pw_command *parse_command_add_spa_lib(const char *line, char **err); static struct pw_command *parse_command_module_load(const char *line, char **err); static struct pw_command *parse_command_exec(const char *line, char **err); @@ -55,6 +56,7 @@ struct command_parse { static const struct command_parse parsers[] = { {"help", "Show this help", parse_command_help}, + {"add-spa-lib", "Add a library that provides a spa factory name regex", parse_command_add_spa_lib}, {"load-module", "Load a module", parse_command_module_load}, {"exec", "Execute a program", parse_command_exec}, {NULL, NULL, NULL } @@ -96,6 +98,46 @@ static struct pw_command *parse_command_help(const char *line, char **err) } static int +execute_command_add_spa_lib(struct pw_command *command, struct pw_core *core, char **err) +{ + int res; + + res = pw_core_add_spa_lib(core, command->args[1], command->args[2]); + if (res < 0) { + asprintf(err, "could not add spa library \"%s\"", command->args[1]); + return res; + } + return 0; +} + +static struct pw_command *parse_command_add_spa_lib(const char *line, char **err) +{ + struct impl *impl; + struct pw_command *this; + + impl = calloc(1, sizeof(struct impl)); + if (impl == NULL) + goto no_mem; + + this = &impl->this; + this->func = execute_command_add_spa_lib; + this->args = pw_split_strv(line, whitespace, 4, &this->n_args); + + if (this->n_args < 3) + goto no_library; + + return this; + + no_library: + asprintf(err, "%s requires <factory-regex> <library-name>", this->args[0]); + pw_free_strv(this->args); + return NULL; + no_mem: + asprintf(err, "no memory"); + return NULL; +} + +static int execute_command_module_load(struct pw_command *command, struct pw_core *core, char **err) { struct pw_module *module; |