mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
sink-input: change bool save_sink to char *preferred_sink
The finial objective is to store the preferred sink name in the sink-input struct, and use module-stream-restore to save and restore it. This patch just replaces the save_sink with preferred_sink, and tries to keep the original logic. Signed-off-by: Hui Wang <hui.wang@canonical.com>
This commit is contained in:
parent
26a66d103f
commit
fbf8716685
6 changed files with 55 additions and 28 deletions
|
|
@ -656,14 +656,14 @@ static void route_sink_input(struct userdata *u, pa_sink_input *si) {
|
|||
pa_assert(u);
|
||||
pa_assert(u->do_routing);
|
||||
|
||||
/* Don't override user or application routing requests. */
|
||||
if (si->save_sink || si->sink_requested_by_application)
|
||||
return;
|
||||
|
||||
/* Skip this if it is already in the process of being moved anyway */
|
||||
if (!si->sink)
|
||||
return;
|
||||
|
||||
/* Don't override user or application routing requests. */
|
||||
if (pa_safe_streq(si->sink->name, si->preferred_sink) || si->sink_requested_by_application)
|
||||
return;
|
||||
|
||||
auto_filtered_prop = pa_proplist_gets(si->proplist, "module-device-manager.auto_filtered");
|
||||
if (auto_filtered_prop)
|
||||
auto_filtered = (pa_parse_boolean(auto_filtered_prop) == 1);
|
||||
|
|
|
|||
|
|
@ -175,14 +175,14 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
|
|||
if (si->sink == sink)
|
||||
continue;
|
||||
|
||||
if (si->save_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;
|
||||
|
||||
/* 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 */
|
||||
|
|
|
|||
|
|
@ -1311,15 +1311,17 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
|
|||
mute_updated = !created_new_entry && (!old->muted_valid || entry->muted != old->muted);
|
||||
}
|
||||
|
||||
if (sink_input->save_sink) {
|
||||
if (sink_input->preferred_sink != NULL) {
|
||||
pa_sink *s;
|
||||
pa_xfree(entry->device);
|
||||
entry->device = pa_xstrdup(sink_input->sink->name);
|
||||
entry->device = pa_xstrdup(sink_input->preferred_sink);
|
||||
entry->device_valid = true;
|
||||
|
||||
device_updated = !created_new_entry && (!old->device_valid || !pa_streq(entry->device, old->device));
|
||||
if (sink_input->sink->card) {
|
||||
s = pa_namereg_get(c, entry->device, PA_NAMEREG_SINK);
|
||||
if (s && s->card) {
|
||||
pa_xfree(entry->card);
|
||||
entry->card = pa_xstrdup(sink_input->sink->card->name);
|
||||
entry->card = pa_xstrdup(s->card->name);
|
||||
entry->card_valid = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1650,14 +1652,14 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
|
|||
if (si->sink == sink)
|
||||
continue;
|
||||
|
||||
if (si->save_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)
|
||||
|
|
@ -1951,12 +1953,13 @@ static void entry_apply(struct userdata *u, const char *name, struct entry *e) {
|
|||
|
||||
if (u->restore_device) {
|
||||
if (!e->device_valid) {
|
||||
if (si->save_sink) {
|
||||
if (si->preferred_sink != NULL) {
|
||||
pa_log_info("Ensuring device is not saved for stream %s.", name);
|
||||
/* If the device is not valid we should make sure the
|
||||
save flag 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. */
|
||||
si->save_sink = false;
|
||||
pa_xfree(si->preferred_sink);
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void*
|
|||
}
|
||||
|
||||
PA_IDXSET_FOREACH(i, old_default_sink->inputs, idx) {
|
||||
if (i->save_sink || !PA_SINK_INPUT_IS_LINKED(i->state))
|
||||
if (pa_safe_streq(i->sink->name, i->preferred_sink) || !PA_SINK_INPUT_IS_LINKED(i->state))
|
||||
continue;
|
||||
|
||||
if (pa_sink_input_move_to(i, sink, false) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue