mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
match: add "key" argument to match different properties
This commit is contained in:
parent
e97ed21892
commit
e0f8ffe41f
1 changed files with 11 additions and 2 deletions
|
|
@ -48,7 +48,8 @@ PA_MODULE_AUTHOR("Lennart Poettering");
|
||||||
PA_MODULE_DESCRIPTION("Playback stream expression matching module");
|
PA_MODULE_DESCRIPTION("Playback stream expression matching module");
|
||||||
PA_MODULE_VERSION(PACKAGE_VERSION);
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||||
PA_MODULE_LOAD_ONCE(TRUE);
|
PA_MODULE_LOAD_ONCE(TRUE);
|
||||||
PA_MODULE_USAGE("table=<filename>");
|
PA_MODULE_USAGE("table=<filename> "
|
||||||
|
"key=<property_key>");
|
||||||
|
|
||||||
#define WHITESPACE "\n\r \t"
|
#define WHITESPACE "\n\r \t"
|
||||||
|
|
||||||
|
|
@ -57,6 +58,7 @@ PA_MODULE_USAGE("table=<filename>");
|
||||||
|
|
||||||
static const char* const valid_modargs[] = {
|
static const char* const valid_modargs[] = {
|
||||||
"table",
|
"table",
|
||||||
|
"key",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -69,6 +71,7 @@ struct rule {
|
||||||
|
|
||||||
struct userdata {
|
struct userdata {
|
||||||
struct rule *rules;
|
struct rule *rules;
|
||||||
|
char *property_key;
|
||||||
pa_subscription *subscription;
|
pa_subscription *subscription;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -199,7 +202,7 @@ static void callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, v
|
||||||
if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx)))
|
if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(n = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME)))
|
if (!(n = pa_proplist_gets(si->proplist, u->property_key)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pa_log_debug("Matching with %s", n);
|
pa_log_debug("Matching with %s", n);
|
||||||
|
|
@ -230,11 +233,14 @@ int pa__init(pa_module*m) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u = pa_xnew(struct userdata, 1);
|
u = pa_xnew(struct userdata, 1);
|
||||||
u->rules = NULL;
|
u->rules = NULL;
|
||||||
u->subscription = NULL;
|
u->subscription = NULL;
|
||||||
m->userdata = u;
|
m->userdata = u;
|
||||||
|
|
||||||
|
u->property_key = pa_xstrdup(pa_modargs_get_value(ma, "key", PA_PROP_MEDIA_NAME));
|
||||||
|
|
||||||
if (load_rules(u, pa_modargs_get_value(ma, "table", NULL)) < 0)
|
if (load_rules(u, pa_modargs_get_value(ma, "table", NULL)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
@ -263,6 +269,9 @@ void pa__done(pa_module*m) {
|
||||||
if (u->subscription)
|
if (u->subscription)
|
||||||
pa_subscription_free(u->subscription);
|
pa_subscription_free(u->subscription);
|
||||||
|
|
||||||
|
if (u->property_key)
|
||||||
|
pa_xfree(u->property_key);
|
||||||
|
|
||||||
for (r = u->rules; r; r = n) {
|
for (r = u->rules; r; r = n) {
|
||||||
n = r->next;
|
n = r->next;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue