[pulseaudio-commits] 3 commits - src/modules
Arun Raghavan
arun at kemper.freedesktop.org
Sat May 7 08:00:30 UTC 2016
src/modules/module-device-manager.c | 42 ++++++++++++++-----------
src/modules/module-filter-apply.c | 60 +++++++++++++++++++++++++++---------
2 files changed, 70 insertions(+), 32 deletions(-)
New commits:
commit fcee3da944703f382209f0638cc4ef5beb8122a9
Author: Arun Raghavan <git at arunraghavan.net>
Date: Fri May 6 11:56:00 2016 +0530
module-device-manager: Refine logic to ignore filtered streams
Rather than entirely ignore streams for which we have automatically
loaded a filter, this makes module-device-manager only avoid rerouting
such streams within their existing filter hierarchy.
If, for example, m-d-m decided to move a stream which is currently
routed to speakers/mic which we requested echo cancellation for, to a
USB headset, the previous logic would disallow such a move even though
it was legitimate.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93443
Signed-off-by: Arun Raghavan <git at arunraghavan.net>
diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index b3115ee..2a0a67f 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -649,9 +649,10 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
}
static void route_sink_input(struct userdata *u, pa_sink_input *si) {
- const char *ignore;
+ const char *auto_filtered_prop;
const char *role;
uint32_t role_index, device_index;
+ bool auto_filtered = false;
pa_sink *sink;
pa_assert(u);
@@ -664,9 +665,9 @@ static void route_sink_input(struct userdata *u, pa_sink_input *si) {
if (!si->sink)
return;
- ignore = pa_proplist_gets(si->proplist, "module-device-manager.ignore");
- if (ignore && (pa_parse_boolean(ignore) == 1))
- return;
+ auto_filtered_prop = pa_proplist_gets(si->proplist, "module-device-manager.auto_filtered");
+ if (auto_filtered_prop)
+ auto_filtered = (pa_parse_boolean(auto_filtered_prop) == 1);
/* It might happen that a stream and a sink are set up at the
same time, in which case we want to make sure we don't
@@ -689,6 +690,13 @@ static void route_sink_input(struct userdata *u, pa_sink_input *si) {
if (!(sink = pa_idxset_get_by_index(u->core->sinks, device_index)))
return;
+ if (auto_filtered) {
+ /* For streams for which a filter has been loaded by another module, we
+ * do not try to execute moves within the same filter hierarchy */
+ if (pa_sink_get_master(si->sink) == pa_sink_get_master(sink))
+ return;
+ }
+
if (si->sink != sink)
pa_sink_input_move_to(si, sink, false);
}
@@ -712,9 +720,10 @@ static pa_hook_result_t route_sink_inputs(struct userdata *u, pa_sink *ignore_si
}
static void route_source_output(struct userdata *u, pa_source_output *so) {
- const char *ignore;
+ const char *auto_filtered_prop;
const char *role;
uint32_t role_index, device_index;
+ bool auto_filtered = false;
pa_source *source;
pa_assert(u);
@@ -730,9 +739,9 @@ static void route_source_output(struct userdata *u, pa_source_output *so) {
if (!so->source)
return;
- ignore = pa_proplist_gets(so->proplist, "module-device-manager.ignore");
- if (ignore && (pa_parse_boolean(ignore) == 1))
- return;
+ auto_filtered_prop = pa_proplist_gets(so->proplist, "module-device-manager.auto_filtered");
+ if (auto_filtered_prop)
+ auto_filtered = (pa_parse_boolean(auto_filtered_prop) == 1);
/* It might happen that a stream and a source are set up at the
same time, in which case we want to make sure we don't
@@ -755,6 +764,13 @@ static void route_source_output(struct userdata *u, pa_source_output *so) {
if (!(source = pa_idxset_get_by_index(u->core->sources, device_index)))
return;
+ if (auto_filtered) {
+ /* For streams for which a filter has been loaded by another module, we
+ * do not try to execute moves within the same filter hierarchy */
+ if (pa_source_get_master(so->source) == pa_source_get_master(source))
+ return;
+ }
+
if (so->source != source)
pa_source_output_move_to(so, source, false);
}
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index c8bb4da..47ef46d 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -38,7 +38,7 @@
#include "module-filter-apply-symdef.h"
#define PA_PROP_FILTER_APPLY_MOVING "filter.apply.moving"
-#define PA_PROP_MDM_IGNORE "module-device-manager.ignore"
+#define PA_PROP_MDM_AUTO_FILTERED "module-device-manager.auto_filtered"
PA_MODULE_AUTHOR("Colin Guthrie");
PA_MODULE_DESCRIPTION("Load filter sinks automatically when needed");
@@ -66,8 +66,8 @@ struct filter {
struct userdata {
pa_core *core;
pa_hashmap *filters;
- /* Keep track of streams we're managing PA_PROP_MDM_IGNORE on, we're only
- * maintaining membership, so key and value are just the
+ /* Keep track of streams we're managing PA_PROP_MDM_AUTO_FILTERED on, we're
+ * only maintaining membership, so key and value are just the
* pa_sink_input/pa_source_output. */
pa_hashmap *mdm_ignored_inputs, *mdm_ignored_outputs;
bool autoclean;
@@ -280,10 +280,10 @@ static int do_move(struct userdata *u, pa_object *obj, pa_object *parent, bool i
pa_hashmap_put(is_input ? u->mdm_ignored_inputs : u->mdm_ignored_outputs, obj, obj);
if (is_input) {
- pa_sink_input_set_property(PA_SINK_INPUT(obj), PA_PROP_MDM_IGNORE, "1");
+ pa_sink_input_set_property(PA_SINK_INPUT(obj), PA_PROP_MDM_AUTO_FILTERED, "1");
return pa_sink_input_move_to(PA_SINK_INPUT(obj), PA_SINK(parent), false);
} else {
- pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), PA_PROP_MDM_IGNORE, "1");
+ pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), PA_PROP_MDM_AUTO_FILTERED, "1");
return pa_source_output_move_to(PA_SOURCE_OUTPUT(obj), PA_SOURCE(parent), false);
}
}
@@ -670,12 +670,12 @@ static pa_hook_result_t source_unlink_cb(pa_core *core, pa_source *source, struc
static void unset_mdm_ignore_input(pa_sink_input *i)
{
- pa_sink_input_set_property(i, PA_PROP_MDM_IGNORE, NULL);
+ pa_sink_input_set_property(i, PA_PROP_MDM_AUTO_FILTERED, NULL);
}
static void unset_mdm_ignore_output(pa_source_output *o)
{
- pa_source_output_set_property(o, PA_PROP_MDM_IGNORE, NULL);
+ pa_source_output_set_property(o, PA_PROP_MDM_AUTO_FILTERED, NULL);
}
int pa__init(pa_module *m) {
commit 4331733c19fb2355008a5e754f93462b7e38e518
Author: Arun Raghavan <git at arunraghavan.net>
Date: Mon Apr 25 18:14:04 2016 +0530
module-filter-apply: Don't implement policy in module-device-manager
This adds an ignore mechanism to module-device-manager and uses that
from within module-filter-apply, rather than having m-d-m have knowledge
of anything related to m-f-a.
Signed-off-by: Arun Raghavan <git at arunraghavan.net>
diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index 0df9575..b3115ee 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -649,7 +649,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
}
static void route_sink_input(struct userdata *u, pa_sink_input *si) {
- const char *filter_device;
+ const char *ignore;
const char *role;
uint32_t role_index, device_index;
pa_sink *sink;
@@ -664,13 +664,8 @@ static void route_sink_input(struct userdata *u, pa_sink_input *si) {
if (!si->sink)
return;
- /* If module-filter-apply has loaded a filter for the stream, let's not
- * break the filtering. The pa_streq() check is needed, because
- * module-filter-apply doesn't unset the property when the stream moves
- * away from the filter device for whatever reason (this is ugly, but
- * easier to do this way than appropriately unsetting the property). */
- filter_device = pa_proplist_gets(si->proplist, "module-filter-apply.filter_device");
- if (filter_device && pa_streq(filter_device, si->sink->name))
+ ignore = pa_proplist_gets(si->proplist, "module-device-manager.ignore");
+ if (ignore && (pa_parse_boolean(ignore) == 1))
return;
/* It might happen that a stream and a sink are set up at the
@@ -717,7 +712,7 @@ static pa_hook_result_t route_sink_inputs(struct userdata *u, pa_sink *ignore_si
}
static void route_source_output(struct userdata *u, pa_source_output *so) {
- const char *filter_device;
+ const char *ignore;
const char *role;
uint32_t role_index, device_index;
pa_source *source;
@@ -735,13 +730,8 @@ static void route_source_output(struct userdata *u, pa_source_output *so) {
if (!so->source)
return;
- /* If module-filter-apply has loaded a filter for the stream, let's not
- * break the filtering. The pa_streq() check is needed, because
- * module-filter-apply doesn't unset the property when the stream moves
- * away from the filter device for whatever reason (this is ugly, but
- * easier to do this way than appropriately unsetting the property). */
- filter_device = pa_proplist_gets(so->proplist, "module-filter-apply.filter_device");
- if (filter_device && pa_streq(filter_device, so->source->name))
+ ignore = pa_proplist_gets(so->proplist, "module-device-manager.ignore");
+ if (ignore && (pa_parse_boolean(ignore) == 1))
return;
/* It might happen that a stream and a source are set up at the
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index 727cc20..c8bb4da 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -38,6 +38,7 @@
#include "module-filter-apply-symdef.h"
#define PA_PROP_FILTER_APPLY_MOVING "filter.apply.moving"
+#define PA_PROP_MDM_IGNORE "module-device-manager.ignore"
PA_MODULE_AUTHOR("Colin Guthrie");
PA_MODULE_DESCRIPTION("Load filter sinks automatically when needed");
@@ -65,6 +66,10 @@ struct filter {
struct userdata {
pa_core *core;
pa_hashmap *filters;
+ /* Keep track of streams we're managing PA_PROP_MDM_IGNORE on, we're only
+ * maintaining membership, so key and value are just the
+ * pa_sink_input/pa_source_output. */
+ pa_hashmap *mdm_ignored_inputs, *mdm_ignored_outputs;
bool autoclean;
pa_time_event *housekeeping_time_event;
};
@@ -270,17 +275,20 @@ static void trigger_housekeeping(struct userdata *u) {
u->housekeeping_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + HOUSEKEEPING_INTERVAL, housekeeping_time_callback, u);
}
-static int do_move(pa_object *obj, pa_object *parent, bool is_input) {
+static int do_move(struct userdata *u, pa_object *obj, pa_object *parent, bool is_input) {
+ /* Keep track of objects that we've marked for module-device-manager to ignore */
+ pa_hashmap_put(is_input ? u->mdm_ignored_inputs : u->mdm_ignored_outputs, obj, obj);
+
if (is_input) {
- pa_sink_input_set_property(PA_SINK_INPUT(obj), "module-filter-apply.filter_device", PA_SINK(parent)->name);
+ pa_sink_input_set_property(PA_SINK_INPUT(obj), PA_PROP_MDM_IGNORE, "1");
return pa_sink_input_move_to(PA_SINK_INPUT(obj), PA_SINK(parent), false);
} else {
- pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), "module-filter-apply.filter_device", PA_SOURCE(parent)->name);
+ pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), PA_PROP_MDM_IGNORE, "1");
return pa_source_output_move_to(PA_SOURCE_OUTPUT(obj), PA_SOURCE(parent), false);
}
}
-static void move_object_for_filter(pa_object *o, struct filter* filter, bool restore, bool is_sink_input) {
+static void move_object_for_filter(struct userdata *u, pa_object *o, struct filter* filter, bool restore, bool is_sink_input) {
pa_object *parent;
pa_proplist *pl;
const char *name;
@@ -304,7 +312,7 @@ static void move_object_for_filter(pa_object *o, struct filter* filter, bool res
pa_proplist_sets(pl, PA_PROP_FILTER_APPLY_MOVING, "1");
- if (do_move(o, parent, is_sink_input) < 0)
+ if (do_move(u, o, parent, is_sink_input) < 0)
pa_log_info("Failed to move %s for \"%s\" to <%s>.", is_sink_input ? "sink-input" : "source-output",
pa_strnull(pa_proplist_gets(pl, PA_PROP_APPLICATION_NAME)), name);
else
@@ -318,7 +326,7 @@ static void move_objects_for_filter(struct userdata *u, pa_object *o, struct fil
bool is_sink_input) {
if (!should_group_filter(filter))
- move_object_for_filter(o, filter, restore, is_sink_input);
+ move_object_for_filter(u, o, filter, restore, is_sink_input);
else {
pa_source_output *so;
pa_sink_input *si;
@@ -331,7 +339,7 @@ static void move_objects_for_filter(struct userdata *u, pa_object *o, struct fil
g = get_group(PA_OBJECT(so), false);
if (pa_streq(g, group))
- move_object_for_filter(PA_OBJECT(so), filter, restore, false);
+ move_object_for_filter(u, PA_OBJECT(so), filter, restore, false);
pa_xfree(g);
}
@@ -340,7 +348,7 @@ static void move_objects_for_filter(struct userdata *u, pa_object *o, struct fil
g = get_group(PA_OBJECT(si), true);
if (pa_streq(g, group))
- move_object_for_filter(PA_OBJECT(si), filter, restore, true);
+ move_object_for_filter(u, PA_OBJECT(si), filter, restore, true);
pa_xfree(g);
}
@@ -520,6 +528,9 @@ static pa_hook_result_t sink_input_move_finish_cb(pa_core *core, pa_sink_input *
if (pa_proplist_gets(i->proplist, PA_PROP_FILTER_APPLY_MOVING))
return PA_HOOK_OK;
+ /* If we're managing m-d-m.ignore 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);
}
@@ -539,6 +550,8 @@ static pa_hook_result_t sink_input_unlink_cb(pa_core *core, pa_sink_input *i, st
if (pa_hashmap_size(u->filters) > 0)
trigger_housekeeping(u);
+ pa_hashmap_remove(u->mdm_ignored_inputs, i);
+
return PA_HOOK_OK;
}
@@ -592,6 +605,9 @@ static pa_hook_result_t source_output_move_finish_cb(pa_core *core, pa_source_ou
if (pa_proplist_gets(o->proplist, PA_PROP_FILTER_APPLY_MOVING))
return PA_HOOK_OK;
+ /* If we're managing m-d-m.ignore 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);
}
@@ -611,6 +627,8 @@ static pa_hook_result_t source_output_unlink_cb(pa_core *core, pa_source_output
if (pa_hashmap_size(u->filters) > 0)
trigger_housekeeping(u);
+ pa_hashmap_remove(u->mdm_ignored_outputs, o);
+
return PA_HOOK_OK;
}
@@ -650,6 +668,16 @@ static pa_hook_result_t source_unlink_cb(pa_core *core, pa_source *source, struc
return PA_HOOK_OK;
}
+static void unset_mdm_ignore_input(pa_sink_input *i)
+{
+ pa_sink_input_set_property(i, PA_PROP_MDM_IGNORE, NULL);
+}
+
+static void unset_mdm_ignore_output(pa_source_output *o)
+{
+ pa_source_output_set_property(o, PA_PROP_MDM_IGNORE, NULL);
+}
+
int pa__init(pa_module *m) {
pa_modargs *ma = NULL;
struct userdata *u;
@@ -672,6 +700,8 @@ int pa__init(pa_module *m) {
}
u->filters = pa_hashmap_new(filter_hash, filter_compare);
+ u->mdm_ignored_inputs = pa_hashmap_new_full(NULL, NULL, (pa_free_cb_t) unset_mdm_ignore_input, NULL);
+ u->mdm_ignored_outputs = pa_hashmap_new_full(NULL, NULL, (pa_free_cb_t) unset_mdm_ignore_output, NULL);
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_move_finish_cb, u);
@@ -719,5 +749,11 @@ void pa__done(pa_module *m) {
pa_hashmap_free(u->filters);
}
+ if (u->mdm_ignored_inputs)
+ pa_hashmap_free(u->mdm_ignored_inputs);
+
+ if (u->mdm_ignored_outputs)
+ pa_hashmap_free(u->mdm_ignored_outputs);
+
pa_xfree(u);
}
commit 87048cc334218e8f33ad4b52f339a0bb27634fb1
Author: Arun Raghavan <git at arunraghavan.net>
Date: Mon Apr 25 16:51:53 2016 +0530
module-filter-apply: Remove some dead code
We never actually pass restore=true, so might as well remove any code
that deals with that case.
Signed-off-by: Arun Raghavan <git at arunraghavan.net>
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index d09efb4..727cc20 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -270,17 +270,13 @@ static void trigger_housekeeping(struct userdata *u) {
u->housekeeping_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + HOUSEKEEPING_INTERVAL, housekeeping_time_callback, u);
}
-static int do_move(pa_object *obj, pa_object *parent, bool restore, bool is_input) {
+static int do_move(pa_object *obj, pa_object *parent, bool is_input) {
if (is_input) {
- if (!restore)
- pa_sink_input_set_property(PA_SINK_INPUT(obj), "module-filter-apply.filter_device", PA_SINK(parent)->name);
-
- return pa_sink_input_move_to(PA_SINK_INPUT(obj), PA_SINK(parent), restore);
+ pa_sink_input_set_property(PA_SINK_INPUT(obj), "module-filter-apply.filter_device", PA_SINK(parent)->name);
+ return pa_sink_input_move_to(PA_SINK_INPUT(obj), PA_SINK(parent), false);
} else {
- if (!restore)
- pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), "module-filter-apply.filter_device", PA_SOURCE(parent)->name);
-
- return pa_source_output_move_to(PA_SOURCE_OUTPUT(obj), PA_SOURCE(parent), restore);
+ pa_source_output_set_property(PA_SOURCE_OUTPUT(obj), "module-filter-apply.filter_device", PA_SOURCE(parent)->name);
+ return pa_source_output_move_to(PA_SOURCE_OUTPUT(obj), PA_SOURCE(parent), false);
}
}
@@ -308,7 +304,7 @@ static void move_object_for_filter(pa_object *o, struct filter* filter, bool res
pa_proplist_sets(pl, PA_PROP_FILTER_APPLY_MOVING, "1");
- if (do_move(o, parent, false, is_sink_input) < 0)
+ if (do_move(o, parent, is_sink_input) < 0)
pa_log_info("Failed to move %s for \"%s\" to <%s>.", is_sink_input ? "sink-input" : "source-output",
pa_strnull(pa_proplist_gets(pl, PA_PROP_APPLICATION_NAME)), name);
else
More information about the pulseaudio-commits
mailing list