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