mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-22 08:56:52 -05:00
alsa-sink/source: Make sure volumes are synchronised after fast user switching
Log in as user A, fast user switch to user B, let user B change port, volume or mute status, then switch back to user A. At this point we must make sure that the ALSA and PA volumes are synchronised by writing to the ALSA mixer when the ALSA device becomes available. BugLink: https://bugs.launchpad.net/bugs/915035 Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
29e4b187a3
commit
6961d3e1c7
6 changed files with 73 additions and 4 deletions
|
|
@ -235,6 +235,7 @@ pa_source* pa_source_new(
|
|||
s->flags = flags;
|
||||
s->priority = 0;
|
||||
s->suspend_cause = 0;
|
||||
pa_source_set_mixer_dirty(s, FALSE);
|
||||
s->name = pa_xstrdup(name);
|
||||
s->proplist = pa_proplist_copy(data->proplist);
|
||||
s->driver = pa_xstrdup(pa_path_get_filename(data->driver));
|
||||
|
|
@ -713,6 +714,12 @@ int pa_source_update_status(pa_source*s) {
|
|||
return source_set_state(s, pa_source_used_by(s) ? PA_SOURCE_RUNNING : PA_SOURCE_IDLE);
|
||||
}
|
||||
|
||||
/* Called from any context - must be threadsafe */
|
||||
void pa_source_set_mixer_dirty(pa_source *s, pa_bool_t is_dirty)
|
||||
{
|
||||
pa_atomic_store(&s->mixer_dirty, is_dirty ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
int pa_source_suspend(pa_source *s, pa_bool_t suspend, pa_suspend_cause_t cause) {
|
||||
pa_source_assert_ref(s);
|
||||
|
|
@ -728,6 +735,27 @@ int pa_source_suspend(pa_source *s, pa_bool_t suspend, pa_suspend_cause_t cause)
|
|||
else
|
||||
s->suspend_cause &= ~cause;
|
||||
|
||||
if (!(s->suspend_cause & PA_SUSPEND_SESSION) && (pa_atomic_load(&s->mixer_dirty) != 0)) {
|
||||
/* This might look racy but isn't: If somebody sets mixer_dirty exactly here,
|
||||
it'll be handled just fine. */
|
||||
pa_source_set_mixer_dirty(s, FALSE);
|
||||
pa_log_debug("Mixer is now accessible. Updating alsa mixer settings.");
|
||||
if (s->active_port && s->set_port) {
|
||||
if (s->flags & PA_SOURCE_DEFERRED_VOLUME) {
|
||||
struct source_message_set_port msg = { .port = s->active_port, .ret = 0 };
|
||||
pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_PORT, &msg, 0, NULL) == 0);
|
||||
}
|
||||
else
|
||||
s->set_port(s, s->active_port);
|
||||
}
|
||||
else {
|
||||
if (s->set_mute)
|
||||
s->set_mute(s);
|
||||
if (s->set_volume)
|
||||
s->set_volume(s);
|
||||
}
|
||||
}
|
||||
|
||||
if ((pa_source_get_state(s) == PA_SOURCE_SUSPENDED) == !!s->suspend_cause)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue