Bluetooth Headphones switches from (A2DP sink) to (HSP/HFP) when starting VoIP application

since a few weeks I have some (more) trouble with my bluetooth headphones Sony WH-H900-N in Ubuntu 18.04 (but also in Linux Mint). It is a headphone with noice cancellation feature. So it does have a microphone for this purpose, but I doubt that it is good enough to use as input for VoIP applications. Instead I would like to use a webcam as microphone input.

So here are my problems:

-I am able to connect the headphones more or less properly, but I have to manually pair it in every session and manually set it to A2DP profile. Using this annoying workaround it works as an high quality audio sink.

-Whenever I connect to any VoIP application (Telegram call, connect to TeamSpeak Server, Skype) for some reason it automatically switches from A2DP audio sink profile to Headset Head Unit (HSP/HFP) Profile. The result is, that I can not hear anything anymore. Neither system sounds, nor the audio from the voice call. People hear me talking though and it seems like the correct microphone is used as input (the webcam, NOT the microphone from the headphones).

Strangely I had no problems with calls until some weeks ago. And this is true for two different systems (Ubuntu, Linux Mint). So I guess there was some recent common update that causes the problems.

Does anybody know how I can fix this issue? To me it seems like permanently setting the headphones as A2DP audio sink and permanently setting the webcam as default microphone input could solve this. But I am not sure how this noice cancellation thing interacts with all this. Plus I don't know how to set things up permanently and I read terrible stories of people trying to manually mess with pulseaudio :)

Any help is appreciated!


Been having this problem for months. Finally got around to googling for a solution and I found this answer on the arch linux forums (from user v1del):

From pulseaudio 10.0 release notes:

Pulse release notes wrote: Bluetooth headsets typically support both the A2DP profile, which is suitable for music, and the HSP profile, which is suitable for telephony use cases. module-bluetooth-policy will now automatically switch the profile of a Bluetooth headset from A2DP to HSP/HFP when an application creates a recording stream with property media.role=phone (telephony applications should set that property for their streams). When the stream goes away, the profile gets restored back to A2DP. This way the user doesn't have to manually switch the profiles when starting and stopping a call. This behaviour can be disabled by giving argument auto_switch=false to module-bluetooth-policy.

Basically you need to change this line in the file /etc/pulse/default.pa:

### Automatically load driver modules for Bluetooth hardware
ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

To:

### Automatically load driver modules for Bluetooth hardware
ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy auto_switch=false
.endif

For ubuntu 21.10 I found that /var/lib/gdm3/.config/pulse/default.pa unloads the module and .config/pulse/default.pa reloads it per user.

The following lines must therefore be changed in ~/.config/pulse/default.pa

## Automatically load driver modules for Bluetooth hardware
ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

To:

### Automatically load driver modules for Bluetooth hardware    
ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy auto_switch=false
.endif