I've managed to fix it. Even though I'm not sure if the following steps are in the exactly order to do it, I'm pretty sure it was the combination of them that fixed it. Here they are:
I've installed Blueman: sudo apt-get install blueman
I've edited the /etc/bluetooth/audio.conf
file: sudo -H gedit /etc/bluetooth/audio.conf
and add this line in the end of it: Disable=Headset
. Users on Ubuntu 17.04 and above may not have audio.conf
, but can instead use main.conf
.
Note: I've also installed something called "pavucontrol" via terminal with the command sudo apt-get install pavucontrol
, but I'm really not sure if it was this or the Blueman that solved it. I suspect it was the Blueman, but if it doesn't help, try the pavucontrol and see if it solves.
Hope this helps!
Sad story,
Seems that your bluetooth card has not a fully compatible driver with bluez or whatever as mine :(.
I solved following this guide and building two stupid scripts
Getting ready
Install ofono
sudo apt install ofono
Config pulseaudio to use ofono:
Provide phonesim to ofono.
In order to make ofono work, you have to provide a modem to it! You can install a modem emulator called phonesim (implemented by ofono) to make it work:
- install ofono-phonesim (in some distros it is called phonesim). in Ubuntu 18.04 (for Ubuntu 20.04 follow this link):
sudo apt install ofono-phonesim
- Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf:
[phonesim]
Driver=phonesim
Address=127.0.0.1
Port=12345
sudo systemctl restart ofono.service
- Clone ofono repository (contains useful scripts)
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git destination/path
Then, every time you want to enable hfp/hsp:
ofono-phonesim -p 12345 /usr/share/phonesim/default.xml &
then use
path/to/cloned/repo/test/enable-modem /phonesim
then restart pulseaudio with
pulseaudio --kill` and `pulseaudio --start
Now you should see a microphone device.
When you want to go back to a2dp:
path/to/cloned/repo/test/disable-modem /phonesim
then restart pulseaudio with
pulseaudio --kill` and `pulseaudio --start
eventually restart pulseeffects with
pulseeffects --quit` and `pulseeffects &
Lately i'm not using this because it's not always working, and so using a jack is faster.
Hope it helps :)
edit: Added getting ready section
edit 2: Added git clone step
Best Answer
The observed profile switching seems to be a feature of PulseAudio 10.0 and above, mentioned in the release notes as "Automatically switch Bluetooth profile when using VoIP applications". To summarise, if A2DP is used, PulseAudio will switch to HFP when an application uses the microphone. This is necessary because A2DP cannot support simultaneous input and output, whereas HFP does.
The following bug reports have more information on the issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/508522 https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1711087
To resolve the problem, you can either edit
/etc/pulse/default.pa
or~/.config/default.pa
, based on your preference. If you decide to use the user configuration file, you may have to create it by copying/etc/pulse/default.pa
. Once you've decided which file you want to edit, find the following line:... and replace it with the following:
The added parameter will stop PulseAudio from performing the profile switching.
I will leave the question open, as this answer doesn't specifically address the issue of enforcing a profile. It does, however, address the cause of switching that I was facing, and hopefully someone else will find it useful.