]> code.delx.au - pulseaudio/blobdiff - src/modules/module-match.c
initialize properties for ALSA sinks/sources more elaborately, re #277
[pulseaudio] / src / modules / module-match.c
index 0155b2af622a8bf2b67c687570cd5d26be6052c6..0411dcdc0c98b9636e1ce6cf9eac5ddd32daf049 100644 (file)
 
 #include "module-match-symdef.h"
 
-PA_MODULE_AUTHOR("Lennart Poettering")
-PA_MODULE_DESCRIPTION("Playback stream expression matching module")
-PA_MODULE_USAGE("table=<filename>")
-PA_MODULE_VERSION(PACKAGE_VERSION)
+PA_MODULE_AUTHOR("Lennart Poettering");
+PA_MODULE_DESCRIPTION("Playback stream expression matching module");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_USAGE("table=<filename>");
 
 #define WHITESPACE "\n\r \t"
 
@@ -165,6 +166,7 @@ static void callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, v
     struct userdata *u =  userdata;
     pa_sink_input *si;
     struct rule *r;
+    const char *n;
 
     pa_assert(c);
     pa_assert(u);
@@ -175,13 +177,13 @@ 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)))
         return;
 
-    if (!si->name)
+    if (!(n = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME)))
         return;
 
     for (r = u->rules; r; r = r->next) {
-        if (!regexec(&r->regex, si->name, 0, NULL, 0)) {
+        if (!regexec(&r->regex, n, 0, NULL, 0)) {
             pa_cvolume cv;
-            pa_log_debug("changing volume of sink input '%s' to 0x%03x", si->name, r->volume);
+            pa_log_debug("changing volume of sink input '%s' to 0x%03x", n, r->volume);
             pa_cvolume_set(&cv, si->sample_spec.channels, r->volume);
             pa_sink_input_set_volume(si, &cv);
         }
@@ -241,5 +243,3 @@ void pa__done(pa_module*m) {
 
     pa_xfree(u);
 }
-
-