- if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SINK, 0)) || target == sink) {
- uint32_t idx;
-
- for (target = pa_idxset_first(c->sinks, &idx); target; target = pa_idxset_next(c->sinks, &idx))
- if (target != sink)
- break;
-
- if (!target) {
- pa_log_info("No evacuation sink found.");
- return PA_HOOK_OK;
- }
+ PA_IDXSET_FOREACH(i, sink->inputs, idx) {
+ pa_sink *target;
+
+ if (!(target = find_evacuation_sink(c, i, sink)))
+ continue;
+
+ if (pa_sink_input_move_to(i, target, 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)), target->name);
+ else
+ pa_log_info("Successfully moved sink input %u \"%s\" to %s.", i->index,
+ pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), target->name);