Understanding PulseAudio profiles and sinks

Hi,

I am trying to understand how PulseAudio profiles are generated and what I could do to change them, because they’re not very satisfactory as-is. I am using KDE, and I’m not sure this is relevant.

I have 2 profiles on my system:

  • HiFi (HDMI1, HDMI2, HDMI3, Mic1, Mic2, Speaker)
  • HiFi (HDMI1, HDMI2, HDMI3, Headphones, Mic1, Mic2)

And I don’t get where they are coming from. The issue here is that the Speaker and the Headphones are on 2 different profiles, meaning I can’t simply change sink, I first need to change the audio profile.

I’m not entirely clear why I need 2 profiles as well. Frustratingly, I find very little documentation on profiles, even though it looks like I can’t do without (most explanation link to a page on Freedesktop that I’m not allowed to link, which is intended for people with hardware not well supported, and is not really helpful in my case).

In the end, the problem I actually have, is that I often connect/disconnect a monitor with no speakers, and somehow PA randomly switches all audio to it. I tried to blacklist it in the configuration:

load-module module-switch-on-port-available blacklist="hdmi|display"
load-module module-switch-on-connect blacklist="hdmi|display"

but alas, that too does not seem to work. It doesn’t switch consistently between headphones and speaker when plugging / unplugging the jack as well. I resorted to writing a script to manually force using a profile/sink. I have something that works but really isn’t elegant. For reference:

#!/usr/bin/bash
# Toggle audio output between speakers/headphones
# PulseAudio sinks are hardcoded, deal with it


# Get the index of the active sink
active_sink=$(pactl list sinks short | grep -E "(RUNNING|IDLE)" | awk '{print $2}')


# Switching sink means:
# - switching to a card profile containing the desired sink
# - making the desired switch the default one (new inputs should automatically spawn on that sink)
# - moving all inputs to the desired sink.
if [ "$active_sink" == 'alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Headphones__sink' ]; then
    echo "Switching to Speakers"
    pactl set-card-profile 0 'HiFi (HDMI1, HDMI2, HDMI3, Mic1, Mic2, Speaker)'
    pactl set-default-sink alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink
    for idx in $(pactl list sink-inputs short | awk '{print $1}') ; do
        pactl move-sink-input "$idx" alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Speaker__sink
    done
else
    echo "Switching to Headphones"
    pactl set-card-profile 0 'HiFi (HDMI1, HDMI2, HDMI3, Headphones, Mic1, Mic2)'
    pactl set-default-sink alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Headphones__sink
    for idx in $(pactl list sink-inputs short | awk '{print $1}') ; do
        pactl move-sink-input "$idx" alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__Headphones__sink
    done
fi

Welcome to the forum! :wave:

FYI, new users are not allowed to post links to combat spammers. Obviously you aren’t one, so for now you can post links surrounded by backticks like this:

`https:///website`

Which appears like this:

https://website

What documentation have you read, what have you tried and what was the result? Without that information, no one can help.

Please see:

Hi,

got it. The only documentation I found directly relating to profiles with PulseAudio was this:
https://www.freedesktop.org/wiki/Software/PulseAudio/Backends/ALSA/Profiles/. It talks about profile but I did not manage to infer, from the example, how I have what I have in my systems.

Considering I spent quite a bit of time trying to figuring it out, and that I couldn’t find a lot of relevant documentation, I’m guessing this is not supposed to be something for users to tinker with!

To start with, I’m not sure if those profiles are generated by KDE / Plasma, or by some other part of Manjaro, which could give me another lead. I tried to grep the keywords I found in my profiles in /usr/share/pulseaudio/alsa-mixer/profile-sets/*, but came up empty-handed.

Oh, in case this is relevant:

Operating System: Manjaro Linux 
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Kernel Version: 6.5.13-7-MANJARO (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i7-1185G7 @ 3.00GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20XW00QGUS
System Version: ThinkPad X1 Carbon Gen 9

that kernel is EOL, better you install 6.6 LTS and you may also try 6.7

HiFi profiles are provided by package alsa-ucm-conf . Use Case Manager profile configurations are located in /usr/share/alsa/ucm2/. The card-specific configuration for sof-hda-dsp is located
in /usr/share/alsa/ucm2/Intel/sof-hda-dsp/

Package alsa-tools includes alsaucm

alsaucm (ALSA Use Case Manager) is a program to use the ALSA Use Case Interface from the command line.

On complex sound cards, setting up audio routes is not trivial and mixer settings can conflict one another preventing the audio card to work at all.

The ALSA Use Case Manager is a mechanism for controlling complex audio hardware establishing a relationship between hardware configurations and meaningful use cases that the end-user can relate with.

PulseAudio module module-switch-on-port-available is part of the default configuration and does not have a blacklist option
module-switch-on-connect is not part of the default configuration because it is considered too aggressive. this module has a blacklist option that blacklists “hdmi” by default

In the end, the problem I actually have, is that I often connect/disconnect a monitor with no speakers, and somehow PA randomly switches all audio to it.

Hi, I wonder if this might help you:
In the KDE menu, choose system settings, then click on Audio. That will bring up a screen. At the very bottom there are two buttons. Click on “Configure…” That pulls up a tiny pop up. Uncheck “Automatically switch all streams when a new output becomes available.”

That’s what I did to solve this issue myself. I hope that helps!
I don’t know enough to help you with the rest of your situation, sorry.

Thanks! I’ll look into alsa-ucm.

You’re correct about module-switch-on-port-available not having a blacklist option, I’ll fix that.

Hi,

thanks for the advice. Unfortunately, it’s already unchecked :frowning:

I think what really irks me is that if I plug my headphones, it switches profile (to the one containing my headphones) and change the sink to my monitor.

If I unplug my headphones, it switches profile to the one containing my speaker and… change the sink to my monitor.

I’m looking for solutions to either blacklist my monitor as a possible sink (it will never have speakers connected, unlike say, if I plug a TV), deprioritize HDMI so that speaker/headphones are always ahead, or… anything I’ve not thought of that could solve this issue.

I’m sorry that didn’t help!
I assume that you have already tried setting the default sink from the pulseaudio system tray pull-up menu?

The only other suggestion I have is to try using Pipewire instead. I recently installed that to try to fix a bluetooth headphone issue. I found it pretty easy to use, but unfortunately Firefox prefers PulseAudio still so every time I touched any web video interface, the volume would reset to full volume. If you don’t use Firefox, that might be wort checking out.

I’m afraid that’s I I’ve got. I hope someone more knowledgeable can get you the help you need.

Unchecking KDE GUI option Automatically switch all streams when a new output becomes available would unload module-switch-on-connect
but the GUI option might not be checked if the module had been loaded by another method:

  • pactl load-module module-switch-on-connect
  • add module to PulseAudio configuration ~/.config/pulse/default.pa
2 Likes

Well that explains why it didn’t work for the OP, thanks.

Hi,

so I just tried installing PipeWire and… it just works. No weird quirk and separate profiles, no more fighting with PulseAudio.

Thanks!

1 Like