}
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);
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
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);
}
}
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);
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
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);
}
#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");
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;
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);
}
}
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) {