If your audio card is continuously switching the output from headphones to speakers, making it impossible to use the sound, well, you are stumpled in a 9 years old bug that’s still unfixed despite the solution is as simple as editing two lines of a text file.
This happens at least on my mint desktop, that is a 12 years old Intel i7 3rd generation, with linux mint 21.1 cinnamon.
The simptoms are the sound level bar that keeps going up and down without any control, and if you open the sound widget, you’ll see the headphones output appearing and disappearing very fast.
In the past the only workaround that I found was to kill pulse audio. It seems it is a bug in the Intel/NVidia driver.
That is: simply edit the
/usr/share/pulseuadio/alsa-mixer/paths/analog-output-headphones.conf file, and comment the following lines:
[Jack Front Headphone] required-any = any ... [Jack Headphone] required-any = any
Restart pulseaudio or, better, reboot, and it will be fixed.
It takes 1 minute or less. But 9 years on the linux community was not enough to find a solution.