Guess: The laptop BIOS is lying to ALSA, and giving it a wrong headphone jack codec node which always detects "connected".
Look at your analog codec with
cat /proc/asound/card*/codec\#*
and use hdajackretask
from package alsa-tools-gui
to correct this if it is true.
Also see here for background information.
I don't know why it happened "suddenly", and can't explain the "sudden" change, but that's the first place I'd look. It's probably unrelated to the distro you are using, and it might have been always broken, and your hardware "suddenly" decided to switch from "undetected" to "detected" for the unused node with open pins. Or something complete different.
Edit
The Pin Complex info provided by the BIOS looks ok (or at least not as jumbled as the "lying" ones I've seen), so maybe it's something else. Try the following: Run evtest
as root, select (in turn) each device that corresponds to soundcard plug events (usually they have HDA Intel
or something similar in the name), and plug in/out your headphone and see if you actually receive events. According to the codec, you should have at least two of those, one for the headphone (Node 0x21) and one for the mic (Node 0x19).
Possibly the headphone/mic jack detection hardware is just broken. Or maybe something completely different.
Speakers are muted when headphones are plugged in by this setting in ALSA
Simple mixer control 'Auto-Mute Mode',0
Capabilities: enum
Items: 'Disabled' 'Enabled'
Item0: 'Enabled'
change this to Disabled
amixer -c0 sset 'Auto-Mute Mode' Disabled
and save ALSA settings so that ALSA keeps settings when system is restored
sudo alsactl store
Best Answer
1. Software switching support
Check, if your sound card supports software switching for the front audio panel. Some older motherboards don't support software switching at all. Some sound cards have connectors for both variants on the motherboard: software and hardware switching. In this case, make sure from your motherboard manual, that you use the connector with software switching.
2. Alsamixer Auto-Mute
Auto-Mute is a feature of Alsa. It ensures that when you connect your headphones, the other audio outputs are automatically muted. You can find and disable this in
alsamixer
. Open AlsaMixer, choose your sound card with F6 then move with < and > and find Auto-Mute. If it's enabled, disable it with the down arrow key.3. PulseAudio configuration
This was the most problematic part for me because PulseAudio is poorly documented. When I disabled AutoMute in the previous step, speakers played in both cases. No matter, if I switched to Headphones or Line-out.
So what I had to do was look into AlsaMixer again and understand, how the volume bars react to audio switching in settings or pavucontrol.
Line-out:
Headphones:
As you can see, after switching to headphones, almost all volume bars got muted. But as I found out after a while, the volume of my speakers is for some reason controlled by Front bar. So now the last thing I had to do, was to configure PulseAudio to mute this Front volume-bar after switching to headphones.
PulseAudio configuration files we need to edit are stored in
/usr/share/pulseaudio/alsa-mixer/paths/
. In my case, I only edited the fileanalog-output-headphones.conf
but this may vary depending on the configuration. You have to edit the file as root to contain these lines:Once you are done, save the file and restart PulseAudio with
pulseaudio -k
.Output switching should now work as expected.