You are not logged in.

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

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

[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: 21,659

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)

Offline

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

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

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: 21,659

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.

Offline

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

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

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

#6 2023-05-07 14:44:52

oceanmattes
Member
Registered: 2023-05-07
Posts: 1

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

Hey,
i'm quite new to arch and i have the same problem but couldn't figure it out on my own...
I installed alsamixer changed the Auto-Mute to disabled, but the problem still remains (without a reboot). As soon as i plug in my headphones the line-out on the back of my motherboard is muted.
Could the problem result in a wrong the default sound-card?
These are my cards:

2 card(s) available.
    index: 0
        name: <alsa_card.pci-0000_1d_00.1>
        driver: <module-alsa-card.c>
        owner module: 6
        properties:
                alsa.card = "0"
                alsa.card_name = "HDA ATI HDMI"
                alsa.long_card_name = "HDA ATI HDMI at 0xfe860000 irq 108"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:1d:00.1"
                sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:1d:00.1/sound/card0"
                device.bus = "pci"
                device.vendor.id = "1002"
                device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
                device.product.id = "aaf0"
                device.product.name = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]"
                device.string = "0"
                device.description = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        profiles:
                output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5900, available: no)
                output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no)
                output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no)
                output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5700, available: no)
                output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no)
                output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no)
                output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5700, available: no)
                output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 600, available: no)
                output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 600, available: no)
                output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 5700, available: no)
                output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 600, available: no)
                output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 600, available: no)
                output:hdmi-stereo-extra4: Digital Stereo (HDMI 5) Output (priority 5700, available: no)
                output:hdmi-surround-extra4: Digital Surround 5.1 (HDMI 5) Output (priority 600, available: no)
                output:hdmi-surround71-extra4: Digital Surround 7.1 (HDMI 5) Output (priority 600, available: no)
                output:hdmi-stereo-extra5: Digital Stereo (HDMI 6) Output (priority 38468, available: unknown)
                off: Off (priority 0, available: unknown)
        active profile: <output:hdmi-stereo-extra5>
        sinks:
                alsa_output.pci-0000_1d_00.1.hdmi-stereo-extra5/#1: Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 6)
        sources:
                alsa_output.pci-0000_1d_00.1.hdmi-stereo-extra5.monitor/#2: Monitor of Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 6)
        ports:
                hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-3: HDMI / DisplayPort 4 (priority 5600, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-5: HDMI / DisplayPort 6 (priority 5400, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "video-display"
                                device.product.name = "U34G2G1"
    index: 1
        name: <alsa_card.pci-0000_1f_00.3>
        driver: <module-alsa-card.c>
        owner module: 7
        properties:
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.long_card_name = "HD-Audio Generic at 0xfe700000 irq 110"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:1f:00.3"
                sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:1f:00.3/sound/card1"
                device.bus = "pci"
                device.vendor.id = "1022"
                device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
                device.product.id = "1457"
                device.product.name = "Family 17h (Models 00h-0fh) HD Audio Controller"
                device.string = "1"
                device.description = "Family 17h (Models 00h-0fh) HD Audio Controller"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        profiles:
                input:analog-stereo: Analog Stereo Input (priority 65, available: no)
                output:analog-stereo: Analog Stereo Output (priority 39268, available: unknown)
                output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6565, available: unknown)
                output:analog-surround-21: Analog Surround 2.1 Output (priority 34068, available: unknown)
                output:analog-surround-21+input:analog-stereo: Analog Surround 2.1 Output + Analog Stereo Input (priority 1365, available: unknown)
                output:analog-surround-40: Analog Surround 4.0 Output (priority 33968, available: unknown)
                output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (priority 1265, available: unknown)
                output:analog-surround-41: Analog Surround 4.1 Output (priority 34068, available: unknown)
                output:analog-surround-41+input:analog-stereo: Analog Surround 4.1 Output + Analog Stereo Input (priority 1365, available: unknown)
                output:analog-surround-50: Analog Surround 5.0 Output (priority 33968, available: unknown)
                output:analog-surround-50+input:analog-stereo: Analog Surround 5.0 Output + Analog Stereo Input (priority 1265, available: unknown)
                output:analog-surround-51: Analog Surround 5.1 Output (priority 34068, available: unknown)
                output:analog-surround-51+input:analog-stereo: Analog Surround 5.1 Output + Analog Stereo Input (priority 1365, available: unknown)
                output:iec958-stereo: Digital Stereo (IEC958) Output (priority 38268, available: unknown)
                output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5565, available: unknown)
                output:iec958-ac3-surround-51: Digital Surround 5.1 (IEC958/AC3) Output (priority 300, available: unknown)
                output:iec958-ac3-surround-51+input:analog-stereo: Digital Surround 5.1 (IEC958/AC3) Output + Analog Stereo Input (priority 365, available: no)
                off: Off (priority 0, available: unknown)
        active profile: <output:analog-stereo+input:analog-stereo>
        sinks:
                alsa_output.pci-0000_1f_00.3.analog-stereo/#0: Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
        sources:
                alsa_output.pci-0000_1f_00.3.analog-stereo.monitor/#0: Monitor of Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
                alsa_input.pci-0000_1f_00.3.analog-stereo/#1: Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo
        ports:
                analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-input-microphone"
                analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-input-microphone"
                analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
                        properties:

                analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: yes)
                        properties:

                analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "audio-headphones"
                iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
                        properties:

And these are my sinks:

2 sink(s) available.
  * index: 0
        name: <alsa_output.pci-0000_1f_00.3.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: (none)
        priority: 9039
        volume: front-left: 11654 /  18% / -45.00 dB,   front-right: 11654 /  18% / -45.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 23.66 ms
        max request: 4 KiB
        max rewind: 4 KiB
        monitor source: 0
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 1
        linked by: 1
        configured latency: 23.22 ms; range is 0.50 .. 1999.82 ms
        card: 1 <alsa_card.pci-0000_1f_00.3>
        module: 7
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC1220 Analog"
                alsa.id = "ALC1220 Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.long_card_name = "HD-Audio Generic at 0xfe700000 irq 110"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:1f:00.3"
                sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:1f:00.3/sound/card1"
                device.bus = "pci"
                device.vendor.id = "1022"
                device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
                device.product.id = "1457"
                device.product.name = "Family 17h (Models 00h-0fh) HD Audio Controller"
                device.string = "front:1"
                device.buffering.buffer_size = "352768"
                device.buffering.fragment_size = "176384"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "Family 17h (Models 00h-0fh) HD Audio Controller Analog Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: yes)
                        properties:

                analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "audio-headphones"
        active port: <analog-output-headphones>
    index: 1
        name: <alsa_output.pci-0000_1d_00.1.hdmi-stereo-extra5>
        driver: <module-alsa-card.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE
        priority: 9030
        volume: front-left: 34451 /  53% / -16.76 dB,   front-right: 34451 /  53% / -16.76 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max request: 0 KiB
        max rewind: 0 KiB
        monitor source: 2
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0.00 ms; range is 0.50 .. 1999.82 ms
        card: 0 <alsa_card.pci-0000_1d_00.1>
        module: 6
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "U34G2G1"
                alsa.id = "HDMI 5"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "11"
                alsa.card = "0"
                alsa.card_name = "HDA ATI HDMI"
                alsa.long_card_name = "HDA ATI HDMI at 0xfe860000 irq 108"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:1d:00.1"
                sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:1d:00.1/sound/card0"
                device.bus = "pci"
                device.vendor.id = "1002"
                device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
                device.product.id = "aaf0"
                device.product.name = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]"
                device.string = "hdmi:0,5"
                device.buffering.buffer_size = "352768"
                device.buffering.fragment_size = "176384"
                device.access_mode = "mmap+timer"
                device.profile.name = "hdmi-stereo-extra5"
                device.profile.description = "Digital Stereo (HDMI 6)"
                device.description = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] Digital Stereo (HDMI 6)"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                hdmi-output-5: HDMI / DisplayPort 6 (priority 5400, latency offset 0 usec, available: yes)
                        properties:
                                device.icon_name = "video-display"
                                device.product.name = "U34G2G1"
        active port: <hdmi-output-5>

Thanks in advance

Offline

#7 2023-05-08 21:34:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,659

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

Did you follow the additional suggestion in the last post?

Offline

Board footer

Powered by FluxBB