mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
sink-input: add a new API pa_sink_input_set_preferred_sink
If the sink here is NULL, that means users want to clear the preferred_sink and move the sink-input to the default_sink, otherwise set the preferred_sink to the sink->name and move the sink-input to the sink. After that fire the sink_input_change event. After adding this API, we can use this API to simplify the entry_apply in the module-stream-restore.c. Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
parent
fbf8716685
commit
24d5d180b8
3 changed files with 18 additions and 8 deletions
|
|
@ -1958,17 +1958,11 @@ static void entry_apply(struct userdata *u, const char *name, struct entry *e) {
|
||||||
/* If the device is not valid we should make sure the
|
/* If the device is not valid we should make sure the
|
||||||
preferred_sink is cleared as the user may have specifically
|
preferred_sink is cleared as the user may have specifically
|
||||||
removed the sink element from the rule. */
|
removed the sink element from the rule. */
|
||||||
pa_xfree(si->preferred_sink);
|
pa_sink_input_set_preferred_sink(si, NULL);
|
||||||
si->preferred_sink = NULL;
|
|
||||||
/* This is cheating a bit. The sink input itself has not changed
|
|
||||||
but the rules governing its routing have, so we fire this event
|
|
||||||
such that other routing modules (e.g. module-device-manager)
|
|
||||||
will pick up the change and reapply their routing */
|
|
||||||
pa_subscription_post(si->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, si->index);
|
|
||||||
}
|
}
|
||||||
} else if ((s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SINK))) {
|
} else if ((s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SINK))) {
|
||||||
pa_log_info("Restoring device for stream %s.", name);
|
pa_log_info("Restoring device for stream %s.", name);
|
||||||
pa_sink_input_move_to(si, s, true);
|
pa_sink_input_set_preferred_sink(si, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2421,3 +2421,17 @@ void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio
|
||||||
pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &i->channel_map, true),
|
pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &i->channel_map, true),
|
||||||
pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &i->channel_map, true));
|
pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &i->channel_map, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called from the main thread. */
|
||||||
|
void pa_sink_input_set_preferred_sink(pa_sink_input *i, pa_sink *s) {
|
||||||
|
pa_assert(i);
|
||||||
|
|
||||||
|
pa_xfree(i->preferred_sink);
|
||||||
|
if (s) {
|
||||||
|
i->preferred_sink = pa_xstrdup(s->name);
|
||||||
|
pa_sink_input_move_to(i, s, false);
|
||||||
|
} else {
|
||||||
|
i->preferred_sink = NULL;
|
||||||
|
pa_sink_input_move_to(i, i->core->default_sink, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,8 @@ void pa_sink_input_set_volume_direct(pa_sink_input *i, const pa_cvolume *volume)
|
||||||
* i->reference_ratio and logs a message if the value changes. */
|
* i->reference_ratio and logs a message if the value changes. */
|
||||||
void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio);
|
void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio);
|
||||||
|
|
||||||
|
void pa_sink_input_set_preferred_sink(pa_sink_input *i, pa_sink *s);
|
||||||
|
|
||||||
#define pa_sink_input_assert_io_context(s) \
|
#define pa_sink_input_assert_io_context(s) \
|
||||||
pa_assert(pa_thread_mq_get() || !PA_SINK_INPUT_IS_LINKED((s)->state))
|
pa_assert(pa_thread_mq_get() || !PA_SINK_INPUT_IS_LINKED((s)->state))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue