[pulseaudio-discuss] [PATCH v2] filter-apply: Fixed a stream moves to wrong sink(or source).

KimJeongYeon see2002 at gmail.com
Mon Apr 10 13:31:36 UTC 2017


For example, a normal stream tried to attach to filter sink(or source), which
filter loaded and managed by filter-apply. But, the stream become to attach to
the ***master sink(or source)*** of filter module due to restoring operation.
It seems should to be attached to the filter sink(or source) properly.

Signed-off-by: KimJeongYeon <jeongyeon.kim at samsung.com>
---
 src/modules/module-filter-apply.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index 364d68b..c5fd9de 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -410,7 +410,7 @@ static bool can_unload_module(struct userdata *u, uint32_t idx) {
     return true;
 }
 
-static pa_hook_result_t process(struct userdata *u, pa_object *o, bool is_sink_input) {
+static pa_hook_result_t process(struct userdata *u, pa_object *o, bool is_put_or_move, bool is_sink_input) {
     const char *want;
     bool done_something = false;
     pa_sink *sink = NULL;
@@ -489,13 +489,24 @@ static pa_hook_result_t process(struct userdata *u, pa_object *o, bool is_sink_i
         }
     } else {
         void *state;
+        pa_proplist *pl;
 
         /* We do not want to filter... but are we already filtered?
          * This can happen if an input's proplist changes */
         PA_HASHMAP_FOREACH(filter, u->filters, state) {
             if ((is_sink_input && sink == filter->sink) || (!is_sink_input && source == filter->source)) {
-                move_objects_for_filter(u, o, filter, true, is_sink_input);
-                done_something = true;
+                /* If a normal stream puts or moves to filter sink which loaded
+                 * by filter-apply, append 'filter.apply' property. */
+                if (is_put_or_move) {
+                    if (is_sink_input)
+                        pl = PA_SINK_INPUT(o)->proplist;
+                    else
+                        pl = PA_SOURCE_OUTPUT(o)->proplist;
+                    pa_proplist_sets(pl, PA_PROP_FILTER_APPLY, filter->name);
+                } else {
+                    move_objects_for_filter(u, o, filter, true, is_sink_input);
+                    done_something = true;
+                }
                 break;
             }
         }
@@ -515,7 +526,7 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core, pa_sink_input *i, struc
     pa_core_assert_ref(core);
     pa_sink_input_assert_ref(i);
 
-    return process(u, PA_OBJECT(i), true);
+    return process(u, PA_OBJECT(i), true, true);
 }
 
 static pa_hook_result_t sink_input_move_finish_cb(pa_core *core, pa_sink_input *i, struct userdata *u) {
@@ -528,14 +539,14 @@ static pa_hook_result_t sink_input_move_finish_cb(pa_core *core, pa_sink_input *
     /* If we're managing m-d-m.auto_filtered on this, remove and re-add if we're continuing to manage it */
     pa_hashmap_remove(u->mdm_ignored_inputs, i);
 
-    return process(u, PA_OBJECT(i), true);
+    return process(u, PA_OBJECT(i), true, true);
 }
 
 static pa_hook_result_t sink_input_proplist_cb(pa_core *core, pa_sink_input *i, struct userdata *u) {
     pa_core_assert_ref(core);
     pa_sink_input_assert_ref(i);
 
-    return process(u, PA_OBJECT(i), true);
+    return process(u, PA_OBJECT(i), false, true);
 }
 
 static pa_hook_result_t sink_input_unlink_cb(pa_core *core, pa_sink_input *i, struct userdata *u) {
@@ -592,7 +603,7 @@ static pa_hook_result_t source_output_put_cb(pa_core *core, pa_source_output *o,
     pa_core_assert_ref(core);
     pa_source_output_assert_ref(o);
 
-    return process(u, PA_OBJECT(o), false);
+    return process(u, PA_OBJECT(o), true, false);
 }
 
 static pa_hook_result_t source_output_move_finish_cb(pa_core *core, pa_source_output *o, struct userdata *u) {
@@ -605,14 +616,14 @@ static pa_hook_result_t source_output_move_finish_cb(pa_core *core, pa_source_ou
     /* If we're managing m-d-m.auto_filtered on this, remove and re-add if we're continuing to manage it */
     pa_hashmap_remove(u->mdm_ignored_outputs, o);
 
-    return process(u, PA_OBJECT(o), false);
+    return process(u, PA_OBJECT(o), true, false);
 }
 
 static pa_hook_result_t source_output_proplist_cb(pa_core *core, pa_source_output *o, struct userdata *u) {
     pa_core_assert_ref(core);
     pa_source_output_assert_ref(o);
 
-    return process(u, PA_OBJECT(o), false);
+    return process(u, PA_OBJECT(o), false, false);
 }
 
 static pa_hook_result_t source_output_unlink_cb(pa_core *core, pa_source_output *o, struct userdata *u) {
-- 
2.7.4



More information about the pulseaudio-discuss mailing list