[pulseaudio-tickets] [Bug 93259] unplugging headphones sets volume to 0

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Feb 16 13:55:15 UTC 2016


https://bugs.freedesktop.org/show_bug.cgi?id=93259

--- Comment #17 from Tanu Kaskinen <tanuk at iki.fi> ---
(In reply to Sergei Sinyak from comment #16)
> I am asking you to forgive me, please. Sorry for not being patient.

You're forgiven :)

> I'd like to code in C/C++ for practice. The real idea is to contribute to
> open source projects. I tried to study radeon module sources previous
> summer, but it went nowhere. Maybe it was really hard task to start with.
> 
> The actual goal was to understand what really happens, which program
> actually goes wrong way. That solution from debuntu.org is not required.
> I've seen that.
> 
> I would pleased, if you can provide some links where i can study work of
> server. Actually about processing plug/unplug events. Because as i see it is
> about incorrect work of gdm too.

There isn't much high-level documentation for the server implementation. The
wiki has some very incomplete and old notes that I wrote when I was new to
PulseAudio (the wiki seems down at the moment, so I can't give a link), and
more recently Ahmed Darwish wrote down his own notes here:
https://a-darwish.gitbooks.io/diary-of-pulseaudio-developement/content/

In any case, feel free to ping me in #pulseaudio in irc (nick: tanuk) when you
have questions about the code. I'm in the channel 24/7, so I'll see your
message regarless of when you send it, but obviously I can't always react
immediately.

About how to fix this bug:

gdm does nothing wrong, this same issue exists also when having two users
logged in simultaneously (one active, one inactive).

The root cause of this bug is that plugging in headphones causes the inactive
user's pulseaudio to change the sink port, and when the port is changed, the
inactive user's pulseaudio also sets the sink volume to what it thinks is
appropriate for headphones. The inactive user's pulseaudio shouldn't touch the
volume while the user is inactive. It would be easy to block mixer changes
while inactive, but it's more complicated to figure out how to restore the
mixer correctly when the user becomes active again.

I think the proper fix is to unload the module-alsa-card instance when udev
revokes the user's access to the card (which happens when the user becomes
inactive). When the user gets access again, the card should be loaded again and
its state should be restored to what it was when the user lost access. However,
I'm pretty sure that we don't currently restore everything properly (for
example, if the default sink was on the unloaded card, I don't think we set the
default sink to the card when it's loaded again). With many unknowns, I'm not
confident that I can implement this solution before 9.0.

A simpler fix/workaround might be to modify module-switch-on-port-available so
that it doesn't do any port/profile switching when the user is inactive.
module-switch-on-port-available is the module that does the decision to switch
from speakers to headphones when headphones are plugged in.
module-switch-on-port-available could collect a queue of unhandled events while
the user is inactive, and process the queue when the user becomes active - that
should restore the mixer to an appropriate state.

Note that I plan to fix this before we start preparing the 9.0 release (code
freeze is planned for 2016-04-21, so that's my deadline). There are a couple of
other bugs that I'll work on first, though, so if you think you can fix this
before me, that would of course be very welcome. But if you prefer to fix
something else, you can have a look at the list of bugs that should be
relatively easy to fix:
https://bugs.freedesktop.org/buglist.cgi?quicksearch=product%3Apulseaudio%20keyword%3Alove&list_id=569621

Starting with an easier bug may be a better way to get yourself familiar with
the code base, but of course it's more motivating to work on a bug that you
suffer yourself.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-bugs/attachments/20160216/984ddde8/attachment.html>


More information about the pulseaudio-bugs mailing list