Unable to properly switch between Speakers and Headphones (has "workaround")
Submitted by gbr..@..il.com
Assigned to pul..@..op.org
Link to original bug (#105654)
Description
Created attachment 138239 pactl list sinks
=== OS: Arch Linux x64 Kernel: 4.15.10 PulseAudio 11.1 Motherboard: B75M-DGS R2.0 (5.1 CH HD Audio (Realtek ALC662 Audio Codec)) [1]
Hi,
I was having trouble making PulseAudio switch the audio output between my headphones and speakers, and most importantly, play audio in them exclusively. My headphone is plugged into the front panel and my speakers are using the rear green connection, and both of them are 2 channel. I was able to find a workaround, which I will demonstrate later, but as of now I'll write like I didn't know of that workaround:
I'm using both ALSA and PulseAudio's default options (although I'm not sure if Arch Linux changes any configuration file).
I have two sinks (see attachment for the output of "pactl list sinks"), but the relevant one is the latter, which holds my headphones and speakers (they're split into two ports).
I'll do my best to reproduce the issue I'm having. I apologize in advance bacause English is not my first language. So, for now let's assume I have only my speakers plugged in (a port identified as "Line Out" in pavucontrol). When I decide to plug in my headphones, here's what happens in pavucontrol:
- The "Line Out" port is set to unplugged and outputs no audio anymore
- The "Headphones" port is set to plugged in and successfully outputs audio
The only problem I see here is that the "Line Out" port was set to "unplugged" (this is about semantics, but it really wasn't phisically unplugged), but no big deal since I'm getting audio exclusively in my headphones, which is exactly what I wanted.
Okay, now that I have both speakers and headphones plugged in, let's say I want to switch back to my speakers. All I would have to do is change the "Port" to "Line Out (unplugged)", but here's what really happens:
- The "Headphones" port gets muted (ok)
- The "Line Out" port DOES NOT get unmuted
- I get no audio output in both of them
Strangely, the "Headphones" port WAS NOT set to "unplugged" like it happened before with "Line Out".
WORKAROUND:
Here's the "workaround" (not sure if you can call it that) I found while messing with alsamixer:
Assuming we're still are in the previous scenario where I had no audio output, if I open "alsamixer -c0" and set the "Auto-Mute Mode" control to "Disabled", I get exclusive audio output in my speakers (which is perfect and exactly what I wanted). Now, let's say I'd switch back to my headphones. The audio does output to my headphones, but not exclusively. So I still hear audio coming from my speakers as well (I don't want that). That's it.
Speaking of that "Auto-Mute Mode" control, the documentation for Linux v4.5 states [2]:
When both headphone and line-out jacks are present, it gives "Disabled", "Speaker Only" and "Line-Out+Speaker".
Well, I do have both of them present, but I the only options I get are: "Disabled" and "Enabled". So there's that as well...
I will be honest to you guys, I've been searching for a solution to this problem for a long time. At the same time, I'm not an expert (not even close to that) about Linux / PulseAudio / ALSA, so there's a high possibility that I might have missed some PulseAudio configuration (I'm really sorry if that's the case).
But based on a lot of Google searches [3][4][5][6], I'm definitely not the only person dealing with that issue, and while I found some possible solutions, none of them really worked for me... There's even a guy saying he has given up [5]. That "workaround" I found was by accident, while I was fiddling with alsamixer. I mean, it does work perfectly for me, but it's very inconvenient having to disable "Auto-Mute Mode" in alsamixer when I want to use my speakers, and then enable it again when I want to use my headphones. If there isn't a solution within PulseAudio or if this is not a bug at all, let me know. I'm sure this could be automated with scripts, but I'm not a programmer, so any help on would be appreciated as well.
Thank you very much.
TL;DR: I wanted to switch between speakers and headphones and output the audio in them EXCLUSIVELY, like you do on Windows [7], but I couldn't do it by default; But I've found a workaround (which is a tad inconvenient when you do it by hand); And I was not sure if this was a bug or not, so I decided to report here just in case.
===
REFERENCES:
[1] http://www.asrock.com/mb/Intel/B75M-DGS%20R2.0/ [2] https://github.com/torvalds/linux/blob/v4.15/Documentation/sound/hd-audio/controls.rst#realtek-codecs [3] https://wiki.archlinux.org/index.php/PulseAudio/Examples#Having_both_speakers_and_headphones_plugged_in_and_switching_in_software_on-the-fly (this was the most promising one, unfortunately it didn't work) [4] https://bbs.archlinux.org/viewtopic.php?id=187828 [5] https://bbs.archlinux.org/viewtopic.php?id=226651 [6] https://bbs.archlinux.org/viewtopic.php?id=161296 [7] https://i.imgur.com/gfKkQcS.png
Attachment 138239, "pactl list sinks":
pactl_list_sinks.txt