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.
This commit is contained in:
Wim Taymans 2022-04-22 14:50:39 +02:00
parent 59461113ba
commit 2402904e1e

View file

@ -897,8 +897,16 @@ int pw_context_conf_update_props(struct pw_context *context,
{ {
struct data data = { .context = context, .props = props }; struct data data = { .context = context, .props = props };
int res; int res;
const char *str = pw_properties_get(props, "config.ext");
res = pw_context_conf_section_for_each(context, section, res = pw_context_conf_section_for_each(context, section,
update_props, &data); 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; 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, .props = props,
.matched = callback, .matched = callback,
.data = data }; .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;
} }