+static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void* userdata) {
+ pa_source_output *o;
+ pa_source *target;
+
+ assert(c);
+ assert(source);
+
+ if (!pa_idxset_size(source->outputs)) {
+ pa_log_debug(__FILE__": No source outputs to move away.");
+ return PA_HOOK_OK;
+ }
+
+ if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE, 0))) {
+ pa_log_info(__FILE__": No evacuation source found.");
+ return PA_HOOK_OK;
+ }
+
+ assert(target != source);
+
+ while ((o = pa_idxset_first(source->outputs, NULL))) {
+ if (pa_source_output_move_to(o, target) < 0) {
+ pa_log_warn(__FILE__": Failed to move source output %u \"%s\" to %s.", o->index, o->name, target->name);
+ return PA_HOOK_OK;
+ }
+
+ pa_log_info(__FILE__": Sucessfully moved source output %u \"%s\" to %s.", o->index, o->name, target->name);
+ }
+
+
+ return PA_HOOK_OK;
+}
+