After extensive testing and research, I have put together a complete work-around for playing high-quality audio through Bluetooth headphones using the Blueman Bluetooth application. This will fix issues with Bluetooth audio in Ubuntu 14.04, and should work in all other versions. I haven’t bothered testing this with other Bluetooth applications. If memory serves me, the alternative Bluetooth apps lack the ability to choose audio profiles – but I might be wrong. Going forward, just understand that this was done exclusively with Blueman.
Default Ubuntu Bluetooth settings work, but don’t work
By default, Ubuntu’s (and other distros’) Bluetooth settings provide working connections to most Bluetooth speakers and smartphones. Heck, using a cheap Bluetooth dongle on your computer, you can share your smart phone’s 4G Internet connection. Works incredibly well. And the same can be said when connecting to your Bluetooth speaker. Using the A2DP (Advanced Audio Distribution Profile) Bluetooth profile setting, today’s modern Bluetooth speakers work well because they only offer one profile – A2DP.
This leads us back to Bluetooth headphones. While there are exceptions, many of these headphones are actually headsets. This means they serve as a means of speaking to others over the phone or VoIP. Complete with a microphone, these headsets are considered to be HSP/HFP (Headset Profile) Bluetooth devices first, A2DP (high quality audio) second.
So here’s the meat of the problem with these headsets acting as headphones – Ubuntu’s default Bluetooth settings don’t like to cooperate with A2DP settings. Just as frustrating, the microphone portion of HSP doesn’t work due to a known bug.
– Bluetooth speakers using A2DP only work fine, and delivers high fidelity audio quality.
– Bluetooth headsets using HSP/A2DP do not. An exception to this might be headsets without HSP profile functionality.
To address this problem, we’re going to be editing some specific files so that we can get Bluetooth headsets to work correctly and provide us with A2DP functionality. This will allow us to enjoy high-quality audio for watching videos, listening to podcasts or simply enjoying our favorite music. Sadly, at this time I haven’t had any luck with getting HSP profiles to allow for microphone compatibility. This may be fixed sometime in the future.
Editing the right conf files
To make things work correctly, we’re going to edit the following.
/etc/Bluetooth/input.conf /usr/bin/start-pulseaudio-x11 /etc/Bluetooth/main.conf /etc/pulse/default.pa
Now, I highly recommend backing up each of these files before editing them. Make sure to make copies of these files with the following commands:
sudo cp /etc/Bluetooth/input.conf /etc/Bluetooth/input.bak
sudo cp /usr/bin/start-pulseaudio-x11 /usr/bin/start-pulseaudio-x11.bak
sudo cp /etc/Bluetooth/main.conf /etc/Bluetooth/main.bak
sudo cp /etc/pulse/default.pa /etc/pulse/default.bak
By backing these files up, you’re able to restore them instantly should you find this doesn’t work with your headset in question. That said, if you follow my instructions, happen to be using bluez 5.37-0ubuntu5, pulseaudio 1:8.0-0ubuntu3.2 running on Ubuntu 16.04, you should have no problem getting this to work.
Important! Be aware that when I updated Ubuntu 16.04 to use a newer version of pulseaudio, I found that the ability to switch audio profiles wasn’t cooperating. I’m still testing the newer version of pulseaudio to see if any additional changes need to be made. Therefore, on my daily PC, I am only running with security updates and various PPAs – I’m not updating recommended or unsupported updates. This will change once I have a chance to better vet the newer pulseaudio package.
First, we have /etc/Bluetooth/input.conf to edit. With each file, my recommendation is to erase the contents of the original and replace it with my edited version of each file.
Erase the original contents of your /etc/Bluetooth/input.conf, then copy the above pastebin and make it your new /etc/Bluetooth/input.conf – the active part here is IdleTimeout=0, which should help prevent your Bluetooth from timing out.
Next we need to edit the /usr/bin/start-pulseaudio-x11 file:
The part of the file that matters here is below:
if [ x"$SESSION_MANAGER" != x ] ; then /usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null fi
Now we begin editing the Bluetooth configuration itself, in /etc/Bluetooth/main.conf:
I won’t bother touching on all the parts of this file that allow stuff to work, but suffice it to say we’re setting this up …