mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-01 13:44:40 +00:00
module-spa: evaluate node and device rules
Before loading the node or device spa plugin, evaluate the node and device rules so that we can use them to configure the plugin properties when it is loaded.
This commit is contained in:
parent
74e340507a
commit
9856500a13
|
@ -92,6 +92,22 @@ void *pw_spa_device_get_user_data(struct pw_impl_device *device)
|
|||
return impl->user_data;
|
||||
}
|
||||
|
||||
struct match {
|
||||
struct pw_properties *props;
|
||||
int count;
|
||||
};
|
||||
#define MATCH_INIT(p) ((struct match){ .props = (p) })
|
||||
|
||||
static int execute_match(void *data, const char *location, const char *action,
|
||||
const char *val, size_t len)
|
||||
{
|
||||
struct match *match = data;
|
||||
if (spa_streq(action, "update-props")) {
|
||||
match->count += pw_properties_update_string(match->props, val, len);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct pw_impl_device *pw_spa_device_load(struct pw_context *context,
|
||||
const char *factory_name,
|
||||
enum pw_spa_device_flags flags,
|
||||
|
@ -102,7 +118,13 @@ struct pw_impl_device *pw_spa_device_load(struct pw_context *context,
|
|||
struct spa_handle *handle;
|
||||
void *iface;
|
||||
int res;
|
||||
struct match match;
|
||||
|
||||
if (properties) {
|
||||
match = MATCH_INIT(properties);
|
||||
pw_context_conf_section_match_rules(context, "device.rules",
|
||||
&properties->dict, execute_match, &match);
|
||||
}
|
||||
handle = pw_context_load_spa_handle(context, factory_name,
|
||||
properties ? &properties->dict : NULL);
|
||||
if (handle == NULL)
|
||||
|
|
|
@ -211,6 +211,22 @@ setup_props(struct pw_context *context, struct spa_node *spa_node, struct pw_pro
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct match {
|
||||
struct pw_properties *props;
|
||||
int count;
|
||||
};
|
||||
#define MATCH_INIT(p) ((struct match){ .props = (p) })
|
||||
|
||||
static int execute_match(void *data, const char *location, const char *action,
|
||||
const char *val, size_t len)
|
||||
{
|
||||
struct match *match = data;
|
||||
if (spa_streq(action, "update-props")) {
|
||||
match->count += pw_properties_update_string(match->props, val, len);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
|
||||
const char *factory_name,
|
||||
|
@ -225,6 +241,7 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
|
|||
void *iface;
|
||||
const struct pw_properties *p;
|
||||
struct pw_loop *loop;
|
||||
struct match match;
|
||||
|
||||
if (properties) {
|
||||
p = pw_context_get_properties(context);
|
||||
|
@ -235,6 +252,11 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
|
|||
if (properties == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
match = MATCH_INIT(properties);
|
||||
pw_context_conf_section_match_rules(context, "node.rules",
|
||||
&properties->dict, execute_match, &match);
|
||||
|
||||
loop = pw_context_acquire_loop(context, &properties->dict);
|
||||
if (loop == NULL) {
|
||||
res = -errno;
|
||||
|
|
Loading…
Reference in a new issue