You are not logged in.

#1 2020-03-23 03:35:07

Captain Rage
Member
Registered: 2012-02-02
Posts: 40

[SOLVED] Make PulseAudio switch between headphones / line out in KDE

Hi,

My system runs KDE and PulseAudio and it would be stellar to find a way make the latter switch between playing sound from the speakers (connected to the back of the motherboard) and the headphones (connected to the front panel, which in turn is connected to the front panel pins on the motherboard) without having to physically disconnect the headphones.
When physically connecting the headphones to the front panel, sound will only be played through the headphones. When unplugging the headphones, sound will only be played through the speakers.
KMix didn't seem to have any fine-grained controls built with PulseAudio in mind, so I uninstalled it and installed plasma-pa instead, which seems to work at least as good with the added benefit of showing more options.
In plasma-pa there is an option to switch between "Headphones" / "Line Out" on the motherboard device ("Starship/Matisse HD Audio Controller"). The former will indeed play sound through the headphones while the latter will make the sound disappear completely.
When switching between both, something changes in alsamixer. Adjusting the bars manually in alsamixer doesn't make any difference (still no sound can be heard).

Is there a way to make PulseAudio, or the system, to switch between playing sound through the speakers and headphones respectively without physically having to disconnect the headphones?

Thank you.

Last edited by Captain Rage (2020-03-26 12:42:43)

Offline

#2 2020-03-23 08:08:09

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,031

Re: [SOLVED] Make PulseAudio switch between headphones / line out in KDE

That's often on a lower level that prevents this from happening, as in the hardware mutes the speakers with a headphone present.

If you check with e.g. amixer -c0 for the controls the hardware provides you will likely find a "Auto-Mute" that's set to enabled, you can disable that, but now audio will usually be routed to both. You might have to end up adjusting port logic with hdajackretask and/or pulse profiles for this, but before we go that far, post some technical information to your HW.

alsa-info.sh
pacmd list-cards
pacmd list-sinks

Last edited by V1del (2020-03-23 08:13:49)

Online

#3 2020-03-26 03:41:38

Captain Rage
Member
Registered: 2012-02-02
Posts: 40

Re: [SOLVED] Make PulseAudio switch between headphones / line out in KDE

Wow, you led me straight to the holy grail. It was only a matter of starting alsamixer, selecting "Line Out" in plasma-pa (it would switch the thingie in alsamixer) and setting "Auto-Mute Mode" from "Enabled" → "Disabled". Voila, now the sound switches as expected when selecting the output in plasma-pa!

Talk about finding a needle in a haystack and not seeing the forest because of all the trees. After having started reading about PulseAudio profiles and configuration in the wiki and despaired (https://wiki.archlinux.org/index.php/PulseAudio/Examples#Having_both_speakers_and_headphones_plugged_in_and_switching_in_software_on-the-fly; something similar was actually described here, but I couldn't understand how to make the corresponding changes to my system, because the configuration on my system looks slightly different, and I glad I didn't start fiddling with those) I was certain it would require some serious tweaking. Fortunately that was not the case.

Here is the info you requested, for curiosity:

[sway@Stargazer paths]$ amixer -c0
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',1
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',2
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',3
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',4
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',5
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]

And alsa-info.sh yielded: http://alsa-project.org/db/?f=0920f2599 … d8882b379b

At least after reading a bit about PulseAudio it became more lucid, which might come in handy in the future. I thank you very much for your help, since having to unplug hardware constantly was a major nuisance. Cheers. smile
Marking the thread as solved. Have a nice day!

Offline

#4 2020-03-26 10:40:49

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 9,031

Re: [SOLVED] Make PulseAudio switch between headphones / line out in KDE

Yes the Auto-Mute mode is one of the "important" controls that pulse usually doesn't adjust itself by default. Glad to hear that toggling this seems to have been sufficient for your usecase.

Online

#5 2020-03-26 13:22:04

Captain Rage
Member
Registered: 2012-02-02
Posts: 40

Re: [SOLVED] Make PulseAudio switch between headphones / line out in KDE

Apparently this was not quite the end of the story, since the settings in alsamixer for Auto-Mute Mode didn't stick after rebooting. Running 'alsactl store' as root created a file called /var/lib/alsa/asound.state with the current alsamixer settings, though, and thankfully it gets loaded automatically on boot and now everything works as I was hoping for. Leaving this piece of info here as a note to self and anybody else to see. Thanks for your help once again. Much obliged. smile


ADDENDUM:
I was too fast to call it a victory. When switching to the speaker port, the headphones were silent and the speakers were playing sound (correct behavior). When switching to the headphone port, the headphones were playing sound and the speakers were playing sound (albeit at an annoyingly low volume; incorrect behavior).

I had to edit the following block in /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf:

; On some machines Front is actually a part of the Headphone path
[Element Front]
switch = mute
volume = zero

to

; On some machines Front is actually a part of the Headphone path
[Element Front]
;switch = mute
switch = off
volume = zero

Now, when setting the option in plasma-pa to "Headphones", sound can be heard ONLY from the headphones, and when setting the option to "Line Out", sound can be heard ONLY from the speakers. Case closed. Phew.

Last edited by Captain Rage (2020-03-27 01:42:24)

Offline

Board footer

Powered by FluxBB