Since I upgraded to Kubuntu 20.04 I have the following problem: when I connect my USB headset, it's automatically configured in A2DP profile, while I need to use it in HSP/HFP profile in order to make phone calls. For reasons outside the scope of this question, the automatic switching from A2DP to HSP/HFP profile does not work with the program I'm using, neither with the default option
module-bluetooth-policy, nor with
auto_switch=2 (the main problem is that this program, which is Linphone, needs the audio sinks be present on startup, before audio even starts, in order to make them selectable for input and output). Therefore, I have to change the headphones profile in the audio system settings from A2DP to HSP/HFP whenever I plug in my headphones and before starting Linphone.
So, after deep investigation (there are many similar questions described here and on other sites) I ended up with the following command:
pactl set-card-profile <my_card_name> headset_head_unit
which works when run from the command line. However, when I add it to
/etc/pulse/default.pa like this:
.ifexists <my_card_name> pactl set-card-profile <my_card_name> headset_head_unit .endif
it does not work, probably because that file is parsed and run on PulseAudio server startup, which is too early. So, I would need to execute that command as soon as the headset is plugged in. Probably a UDEV rule is needed, but it's beyond my skills.
Or, some way to change the profile priority in PulseAudio would also make the trick without any UDEV rule;
pactl list shows (translating from Italian):
Card #3 Name: <my_card_name> Driver: module-bluez5-device.c Owning module: 24 Properties: device.description = "Mpow M5" device.string = "<MAC address>" device.api = "bluez" device.class = "sound" device.bus = "bluetooth" device.form_factor = "headset" bluez.path = "/org/bluez/hci0/dev_<MAC address>" bluez.class = "0x240404" bluez.alias = "Mpow M5" device.icon_name = "audio-headset-bluetooth" device.intended_roles = "phone" Profiles: headset_head_unit: Headset head unit (HSP/HFP) (sink: 1, sources: 1, priority: 30, available: yes) a2dp_sink: High-fidelity playback (sink A2DP) (sink: 1, sources: 0, priority: 40, available: yes) off: Off (sink: 0, sources: 0, priority: 0, available: yes) Active profile: headset_head_unit Ports: headset-output: Headphones with microphone (priority: 0, latency offset: 0 usec, available) Profiles: headset_head_unit, a2dp_sink headset-input: Headphones with microphone (priority: 0, latency offset: 0 usec, available) Profiles: headset_head_unit
Perhaps, if I could change that
priority: 30 to (say)
priority: 50, I could tell PulseAudio to prefer HSP/HFP profile over A2DP. However, I could not find any hint on PulseAudio documentation or on the net on how to change that value.