#include <pulsecore/core.h>
#include <pulsecore/sink-input.h>
#include <pulsecore/source-output.h>
+#include <pulsecore/source.h>
#include <pulsecore/modargs.h>
#include <pulsecore/log.h>
#include <pulsecore/namereg.h>
PA_MODULE_AUTHOR("Michael Terry");
PA_MODULE_DESCRIPTION("When a sink/source is added, switch to it");
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
static const char* const valid_modargs[] = {
NULL,
}
PA_IDXSET_FOREACH(i, def->inputs, idx) {
- if (i->save_sink)
+ if (i->save_sink || !PA_SINK_INPUT_IS_LINKED(i->state))
continue;
- if (pa_sink_input_move_to(i, sink, FALSE) < 0)
+ if (pa_sink_input_move_to(i, sink, false) < 0)
pa_log_info("Failed to move sink input %u \"%s\" to %s.", i->index,
pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), sink->name);
else
- pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index,
+ pa_log_info("Successfully moved sink input %u \"%s\" to %s.", i->index,
pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), sink->name);
}
if (c->state != PA_CORE_RUNNING)
return PA_HOOK_OK;
+ /* Don't switch to a monitoring source */
+ if (source->monitor_of)
+ return PA_HOOK_OK;
+
/* Don't switch to any internal devices */
if ((s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS))) {
if (pa_streq(s, "pci"))
}
PA_IDXSET_FOREACH(o, def->outputs, idx) {
- if (o->save_source)
+ if (o->save_source || !PA_SOURCE_OUTPUT_IS_LINKED(o->state))
continue;
- if (pa_source_output_move_to(o, source, FALSE) < 0)
+ if (pa_source_output_move_to(o, source, false) < 0)
pa_log_info("Failed to move source output %u \"%s\" to %s.", o->index,
pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), source->name);
else
- pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index,
+ pa_log_info("Successfully moved source output %u \"%s\" to %s.", o->index,
pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), source->name);
}