]> code.delx.au - pulseaudio/commitdiff
filter-heuristics: Match roles correctly
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Fri, 22 Apr 2011 14:27:29 +0000 (19:57 +0530)
committerColin Guthrie <colin@mageia.org>
Sat, 23 Apr 2011 17:23:38 +0000 (18:23 +0100)
src/modules/module-filter-heuristics.c

index 4fba29132085ddd534d02586101bed5fc97a9360..1285c46e9a9c35d40f484df19a0b65fc91a22d3a 100644 (file)
@@ -54,8 +54,29 @@ struct userdata {
         *source_output_move_finish_slot;
 };
 
+static pa_bool_t role_match(pa_proplist *proplist, const char *role) {
+    const char *ir;
+    char *r;
+    const char *state = NULL;
+
+    if (!(ir = pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES)))
+        return FALSE;
+
+    while ((r = pa_split_spaces(ir, &state))) {
+
+        if (pa_streq(role, r)) {
+            pa_xfree(r);
+            return TRUE;
+        }
+
+        pa_xfree(r);
+    }
+
+    return FALSE;
+}
+
 static pa_hook_result_t process(struct userdata *u, pa_object *o, pa_bool_t is_sink_input) {
-    const char *want, *int_role, *stream_role;
+    const char *want, *stream_role;
     pa_proplist *pl, *parent_pl;
 
     if (is_sink_input) {
@@ -78,7 +99,7 @@ static pa_hook_result_t process(struct userdata *u, pa_object *o, pa_bool_t is_s
     }
 
     /* On phone sinks, make sure we're not applying echo cancellation */
-    if ((int_role = pa_proplist_gets(parent_pl, PA_PROP_DEVICE_INTENDED_ROLES)) && strstr(int_role, "phone")) {
+    if (role_match(parent_pl, "phone")) {
         const char *apply = pa_proplist_gets(pl, PA_PROP_FILTER_APPLY);
 
         if (apply && pa_streq(apply, "echo-cancel")) {