conf: implement match rules with conf_section_for_each

This commit is contained in:
Wim Taymans 2022-02-01 16:35:16 +01:00
parent 0ac87a14cd
commit 432f464297
2 changed files with 26 additions and 15 deletions

View file

@ -3093,6 +3093,19 @@ static int execute_match(void *data, const char *action, const char *val, int le
return 1; return 1;
} }
static int apply_jack_rules(void *data, const char *location, const char *section,
const char *str, size_t len)
{
struct client *client = data;
const struct pw_properties *p =
pw_context_get_properties(client->context.context);
if (p != NULL)
pw_jack_match_rules(str, len, &p->dict, execute_match, client);
return 0;
}
SPA_EXPORT SPA_EXPORT
jack_client_t * jack_client_open (const char *client_name, jack_client_t * jack_client_open (const char *client_name,
jack_options_t options, jack_options_t options,
@ -3157,14 +3170,8 @@ jack_client_t * jack_client_open (const char *client_name,
pw_properties_update_string(client->props, str, strlen(str)); pw_properties_update_string(client->props, str, strlen(str));
if ((str = pw_context_get_conf_section(client->context.context, pw_context_conf_section_for_each(client->context.context, "jack.rules",
"jack.rules")) != NULL) { apply_jack_rules, client);
const struct pw_properties *p =
pw_context_get_properties(client->context.context);
if (p != NULL)
pw_jack_match_rules(str, strlen(str), &p->dict,
execute_match, client);
}
client->show_monitor = pw_properties_get_bool(client->props, "jack.show-monitor", true); client->show_monitor = pw_properties_get_bool(client->props, "jack.show-monitor", true);
client->merge_monitor = pw_properties_get_bool(client->props, "jack.merge-monitor", false); client->merge_monitor = pw_properties_get_bool(client->props, "jack.merge-monitor", false);

View file

@ -170,15 +170,19 @@ static int client_rule_matched(void *data, const char *action, const char *val,
return 0; return 0;
} }
static int apply_pulse_rules(void *data, const char *location, const char *section,
const char *str, size_t len)
{
struct client *client = data;
pw_conf_match_rules(str, len, &client->props->dict,
client_rule_matched, client);
return 0;
}
int client_update_quirks(struct client *client) int client_update_quirks(struct client *client)
{ {
struct impl *impl = client->impl; struct impl *impl = client->impl;
struct pw_context *context = impl->context; struct pw_context *context = impl->context;
const char *rules; return pw_context_conf_section_for_each(context, "pulse.rules",
apply_pulse_rules, client);
if ((rules = pw_context_get_conf_section(context, "pulse.rules")) == NULL)
return 0;
return pw_conf_match_rules(rules, strlen(rules), &client->props->dict,
client_rule_matched, client);
} }