Linux – ALSA PulseAudio sound output when switching between headphones and laptop speaker

alsaaudiolinuxpulse-audio

Since I installed PulseAudio on my Gentoo system I've been having no audio output from my laptop's speakers when un-plugging the headphones jack.

I suppose the problem lies in how ALSA and PulseAudio manage the audio controls.
When headphones are plugged everything is perfectly ok, alsa controls for the Intel HDA PCH are configured correctly so that 'Master' and 'Headphones' volume bars are correctly configured (I can tell this by looking at alsamixer with root privileges).
When I un-plug the headphone jack, volume settings automatically change in a apparently correct way. That is, the 'Headphone' bar is muted and set to 0, while the 'Speaker' bar is un-muted and maxed out (while it gets muted when plugging the headphone jack). The 'Master' is always left un-muted and with the desired volume level.
I can actually make the speakers output work by manually un-mute and pump-up the headphones output with alsamixer. But I would have to do this operation every time a plug/un-plug headphones.
So is there some way to fix this? Maybe somehow decouple headphones output from speaker output in the ALSA system?

My laptop is an HP Pavilion G6 from 2011.

Thanks.

Best Answer

Edit the file /usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf and locate the section:

[Element Headphone]

And comment the lines

switch = off
volume = off

The end result will be

[Element Headphone]
#switch = off
#volume = off

The problem, in my case was being caused because the channel "Headphones" was being muted, and for some reason, it needs not to be muted for the notebook's speakers to work.

With my change, the headphones don't mute nor get the volume set to zero when unplugging the headphones.

To "debug" which channel is being muted in your case, you can use alsamixer, and inside alsamixer you can press "C" to select your audiocard (the default is setting the volumes for pulseaudio main channels). Plug and unplug the headphones and check what changes.

Related Question