*sink_input_fixate_hook_slot,
*source_output_new_hook_slot,
*source_output_fixate_hook_slot,
- *sink_put_hook_slot,
*source_put_hook_slot,
*sink_unlink_hook_slot,
*source_unlink_hook_slot,
return PA_HOOK_OK;
}
-static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct userdata *u) {
- pa_sink_input *si;
- uint32_t idx;
-
- pa_assert(c);
- pa_assert(sink);
- pa_assert(u);
- pa_assert(u->on_hotplug && u->restore_device);
-
- PA_IDXSET_FOREACH(si, c->sink_inputs, idx) {
- char *name;
- struct entry *e;
-
- if (si->sink == sink)
- continue;
-
- /* Skip this if it is already in the process of being moved
- * anyway */
- if (!si->sink)
- continue;
-
- if (pa_safe_streq(si->sink->name, si->preferred_sink))
- continue;
-
- /* Skip this sink input if it is connecting a filter sink to
- * the master */
- if (si->origin_sink)
- continue;
-
- /* 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
- interfere with that */
- if (!PA_SINK_INPUT_IS_LINKED(si->state))
- continue;
-
- if (!(name = pa_proplist_get_stream_group(si->proplist, "sink-input", IDENTIFICATION_PROPERTY)))
- continue;
-
- if ((e = entry_read(u, name))) {
- if (e->device_valid && pa_streq(e->device, sink->name))
- pa_sink_input_move_to(si, sink, true);
-
- entry_free(e);
- }
-
- pa_xfree(name);
- }
-
- return PA_HOOK_OK;
-}
-
static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, struct userdata *u) {
pa_source_output *so;
uint32_t idx;
if (restore_device && on_hotplug) {
/* A little bit earlier than module-intended-roles ... */
- pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_put_hook_callback, u);
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE, (pa_hook_cb_t) source_put_hook_callback, u);
}
c->mainloop->time_restart(e, pa_timeval_rtstore(&tv, usec, true));
}
+void pa_core_move_streams_to_newly_available_preferred_sink(pa_core *c, pa_sink *s) {
+ pa_sink_input *si;
+ uint32_t idx;
+
+ pa_assert(c);
+ pa_assert(s);
+
+ PA_IDXSET_FOREACH(si, c->sink_inputs, idx) {
+ if (si->sink == s)
+ continue;
+
+ if (!si->sink)
+ continue;
+
+ /* Skip this sink input if it is connecting a filter sink to
+ * the master */
+ if (si->origin_sink)
+ continue;
+
+ /* 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
+ interfere with that */
+ if (!PA_SINK_INPUT_IS_LINKED(si->state))
+ continue;
+
+ if (pa_safe_streq(si->preferred_sink, s->name))
+ pa_sink_input_move_to(si, s, false);
+ }
+
+}
+
/* Helper macro to reduce repetition in pa_suspend_cause_to_string().
* Parameters:
* char *p: the current position in the write buffer