From 2402904e1e7f1af0a924eacfcc7b883577711124 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 22 Apr 2022 14:50:39 +0200 Subject: [PATCH] conf: support config section extensions Add support for loading an additional config section when the config.ext property was set. This makes it possible to have per module config of stream.properties and rules sections. One use case is when there are multiple module-protocol-pulse modules loaded where each module will use a different set of *.properties and *.rules from the config. Each module will have a config.ext property in the args with the suffix of the section that is loaded. --- src/pipewire/conf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index bd2fe1f0a..4e6fc2ca0 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -897,8 +897,16 @@ int pw_context_conf_update_props(struct pw_context *context, { struct data data = { .context = context, .props = props }; int res; + const char *str = pw_properties_get(props, "config.ext"); + res = pw_context_conf_section_for_each(context, section, + update_props, &data); + if (res == 0 && str != NULL) { + char key[128]; + snprintf(key, sizeof(key), "%s.%s", section, str); + res = pw_context_conf_section_for_each(context, key, update_props, &data); + } return res == 0 ? data.count : res; } @@ -1049,5 +1057,16 @@ int pw_context_conf_section_match_rules(struct pw_context *context, const char * .props = props, .matched = callback, .data = data }; - return pw_context_conf_section_for_each(context, section, match_rules, &match); + int res; + const char *str = spa_dict_lookup(props, "config.ext"); + + res = pw_context_conf_section_for_each(context, section, + match_rules, &match); + if (res == 0 && str != NULL) { + char key[128]; + snprintf(key, sizeof(key), "%s.%s", section, str); + res = pw_context_conf_section_for_each(context, key, + match_rules, &match); + } + return res; }