Posted in How To

Ubuntu Bluetooth Headphones Fix

Ubuntu Bluetooth Headphones Fix Posted on January 30, 202419 Comments
Freedom Penguin’s founder & talking head – Matt has over a decade working with Linux desktops, his operating system experience consists of both Windows and Linux operating platforms. In addition to writing articles on Linux and open source technology for Datamation.com and OpenLogic.com/wazi, Matt also once served as a co-host for a popular Linux-centric podcast. Matt has written about various software titles, such as Moodle, Joomla, WordPress, openCRX, Alfresco, Liferay and more. He also has additional Linux experience working with Debian based distributions, openSUSE, CentOS, and Arch Linux.
(Last Updated On: April 13, 2024)

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. 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.

Bluetooth Working

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.

Bluetooth Speaker

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) 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.

Let’s summarize:

- Bluetooth speakers using A2DP only work fine.
- 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.

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.

http://pastebin.com/nzzTQCUT

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:

http://pastebin.com/TSkxbQh6

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:

http://pastebin.com/CSH9dtVp

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 with a minimal configuration.

Then finally, we have our system wide pulseaudio settings in /etc/pulse/default.pa:

http://pastebin.com/q1jB7qDs

In this file, you can find the changes by looking for Matt in the code. I added it for the sections that I tweaked for this file. For this file, I made changes to “load-module module-udev-detect tsched=0” and “load-module module-suspend-on-idle timeout=30.” Once again, this is informational only. You should be copying and pasting the entire configuration for each file after removing the original contents.

And that’s it! Assuming you backed up the original files, emptied the original file(s) contents, and pasted in my tweaked versions – you’re all ready to reboot your PC.

Blueman is the way to Bluetooth

With the computer rebooted, plug in your Linux compatible Bluetooth dongle. If your have Bluetooth installed on a laptop, just keep reading.

sudo apt install blueman

Now run Blueman, and then “Turn Bluetooth On” from the applet itself. Again from the applet, you will want to toggle down to Devices. First, put your headset into discoverable mode and then click Search on Blueman. Once Blueman detects the device, right click on the representative entry in Blueman, click Pair and then Trust.

Once the headset connects (it might take a moment), right click on the entry again and change the profile to Off. Turn off the headset. Now turn the headset on again, and then right click on entry and this time select the A2DP profile. From this moment on, you’re ready to listen to high quality audio through your Bluetooth headset.

So what about when you’re done with the headset? Well, you will need to stop the audio (music, etc) you’re listening to. Then go back to Blueman, right click on the entry and change the profile back to off. From here, you’re free to turn off and charge your headset.

The best part is that when you connect, your default sound device becomes the Bluetooth headset - automatically! And yes kids, this will work on other HSP/A2DP headsets as well.

Using Bluetooth headset on a daily basis:

Bluetooth Off

Once set up, here are the usage instructions

- Turn on headset, switch entry profile to A2DP – enjoy.

When finished listening to headset…

- switch Bluetooth entry profile to Off – turn off headset.

This last part is literally all there is to it now that we did the heavy lifting with the initial setup.

A2DP Profile

Equipment used for Bluetooth Audio

- Levn M32-black Hi-fi V+4.1 Stereo Bluetooth Headset
- Plugable USB Bluetooth 4.0 Low Energy Micro Adapter

I also tested this using another HSp/A2DP headset that was earbud in nature and tried this on a MBP running Ubuntu MATE, with built in Bluetooth. This also worked!

Troubleshooting Bluetooth Audio

Ideally Bluetooth audio should play perfectly. But that’s not the nature of Bluetooth technology being piped through your desktop computer. Sometimes lag can get the better of the situation.

Problem: Bluetooth pairs and connects, but you can’t change profile.

Solution:
- Erase your changed config files (you backed up the originals), try again following the above guide.
- Verify you’re using bluez 5.37-0ubuntu5, pulseaudio 1:8.0-0ubuntu3.2 on Ubuntu 16.04 LTS. I still need to test the newer releases of both packages before signing off on them.

Problem: Bluetooth works, but then it starts skipping and disconnects.

Solution:
- Use a USB extension cable if you’re using a Bluetooth dongle on a desktop PC.
- Position Bluetooth dongle closer to where you use your headset.
- Sometimes bringing up dialog boxes or other PC activity can in rare cases make things skip.
- Some javascript heavy pages loading can in some systems, allow your audio to skip.
- Perhaps most importantly, returning from a PC suspend state can add latency and create skipping.
- Other considerations that can interfere with Bluetooth can be found here.

More great Linux goodness!

Matt Hartley
Matt Hartley
Freedom Penguin’s founder & talking head – Matt has over a decade working with Linux desktops, his operating system experience consists of both Windows and Linux operating platforms. In addition to writing articles on Linux and open source technology for Datamation.com and OpenLogic.com/wazi, Matt also once served as a co-host for a popular Linux-centric podcast.

Matt has written about various software titles, such as Moodle, Joomla, WordPress, openCRX, Alfresco, Liferay and more. He also has additional Linux experience working with Debian based distributions, openSUSE, CentOS, and Arch Linux.

19
Leave a Reply

Please Login to comment
9 Comment threads
10 Thread replies
5 Followers
 
Most reacted comment
Hottest comment thread
11 Comment authors
ashokeSuperMinBryan Lee RagonKocikJacob Beard Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jay LaCroix
Member
Jay LaCroix

I’ve been having issues with my Bluetooth headphones on Ubuntu, but I’m not sure that my problem is the same as yours so I’m not sure if your tweak will work for me. On my end, when I pair my headphones, they will work great the first time. I basically pair them, switch to the appropriate profile, then open pavucontrol to configure it to send audio to my headphones. This all works. But I have the following issues: 1.) When I turn my headphones off and then on, I have to reconfigure pavucontrol again to send audio to my headphones.… Read more »

Matt Hartley
Member
Matt Hartley

Hi Jay, Based on what your describing, yes, this tweak will fix things as I described above using Blueman - make BT audio sound work reliably - however, you will not merely turn on BT and have the profile switch, you need to do that as mentioned in the article. Also, this will make your default sound card (playback) the Bluetooth headphones once the profile is switched to A2DP - automatically. You do not need to touch pavucontrol to switch devices. When Bluetooth disconnects, your speakers will resume their normal active duties. This approach also backsups the changed files using… Read more »

disqus_hN2pyRSnG3
Guest
disqus_hN2pyRSnG3

That’s a giant sized PITA for these newbs with a $5 bluetooth dongle. That config should be defaulted in Ubuntu if it works.

Matt Hartley
Member
Matt Hartley

I agree it’s a PITA, however this is a long standing issue with Bluez/pulseaudio affecting other distros as well. Ubuntu just pulls from what’s available. Having experienced similar stuff with Bluetooth in Windows, I’ve found the difference here is I can find a fix - in Windows, if it’s a no-go, you’re just boned short of a manufacturer fix. 😉

Szymon Stasik
Guest
Szymon Stasik

What is the well known bug affecting the HSP/HFP? I’m trying to find the real reason blocking the use of microphone with linux recently

quage
Member
quage

Hello Matt, thanks for this post. I’m running Mint 18 Cinnamon and trying to (re-)connect devices involved a ridiculous amount to turning things off and turning them back on again. Your settings overcome that (mostly). Here are some extra notes for anyone else anyone else running Mint 18 Cinnamon: 1) “Blueman” = “Bluetooth Manager” and “Turn Bluetooth On” = “Enable Bluetooth” 2) Right-click Pair doesn’t work - you need to use Setup 3) Turn your headset off and back on again after initial pairing 4) Mic won’t work at all because /usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py still has a bug - see https://github.com/linuxmint/Cinnamon/issues/5472 -… Read more »

SuperMin
Admin
SuperMin

Haven’t had need of number 6 myself, so if works, awesome. Perhaps #6 helps with the lag after resume (only time I have had lag on my i7). I’ll have to play with it later.

Remember folks, back up those files before making changes. Even simple ones. Helps if you walk away and forget when you changed later. 🙂

quage
Member
quage

Well, it turns out that #6 did not fix the audio problems. After a fresh restart and auto-connect of my headphones to A2DP the problems were back. Part of the procedure described in this post involves swapping audio profiles between A2DP and HSP/HFP and this apparently causes Pulse to resync. It’s a bug that’s been around for a long time: https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1211102 and I can confirm that, if I manually switch to HSP/HFP and then back to A2DP, audio is clean and in sync.

SuperMin
Admin
SuperMin

…and auto-connect of my headphones to A2DP the problems were back.

As per this article, you cannot autoconnect - you merely need set things up once as described above. Then…

– Turn on headset, switch entry profile to A2DP – enjoy.

When finished listening to headset…

– switch Bluetooth entry profile to Off – turn off headset.

Also, I found #6 didn’t actually do anything on two different computers, so I didn’t include it in the article. Autoconnection is a nice idea, but hardly needed. 🙂

Amanda
Guest
Amanda

Using this fix allows me to play the “Front left/front right” test sounds from sound settings in my headset, but audio from any other application continues to play through my laptop speakers.

SuperMin
Admin
SuperMin

Good news is that the issue described is addressed in an upcoming article as it’s a routing issues in general, not a bluetooth one. Step one, ignore the default volume controls. If you have more than one sound card, it’s a hassle as it sticks to defaults and not to application specific settings. And yes, the fact that this isn’t installed as the default mystifies me as well. 🙂 Assuming Ubuntu/Mint, install the pavucontrol sudo apt update && sudo apt install pavucontrol -y Run it Ctrl and F2 - then pavucontrol With it open compare it to the default sound… Read more »

Amanda
Guest
Amanda

Thanks; I installed pavucontrol, but it doesn’t seem to make a difference. It shows the headset, but it doesn’t seem to have an option to make sound play from there instead of the laptop speakers. (The headset was automatically selected as the “fallback” option, but that didn’t seem to make a difference.)

SuperMin
Admin
SuperMin

Hi Amanda,

So you installed, played audio through the speakers and then jumped to Playback tab with audio still playing and toggled to the headset in the Playback tab?

If so, did it immediately revert back to the speakers (visually speaking) within the Playback tab? This will help me better understand.

Also, which distro and version are you using. I run Ubuntu 16.04 all updates disabled except for security updates enabled.

Amanda
Guest
Amanda

Whatever the issue was, another restart of my computer solved it. So, thanks for the guide!

Jacob Beard
Member
Jacob Beard

Hi,

I wanted to confirm that the instructions in your article worked well for me: BT-QC25 bluetooth headphone adapter, and onboard bluetooth for my Lenovo ThinkPad W520, on Ubuntu 16.04. Thank you for taking the time to document this solution.

Kocik
Member
Kocik

Thanks man, works perfectly 🙂

Bryan Lee Ragon
Member
Bryan Lee Ragon

Since upgrading to 17.10 I have had huge Bluetooth lag and stuttering issues. Every few weeks I tried some searches to fix the problem. Finally found your solution. I don’t know about 16.04 but 17.10 auto connect appears to work. I followed your guide, rebooted, paired my Bose QuietComfort 35ii, set the profile to A2DP and everything worked. I turned off my headset, and saw in Blueman that it was disconnected. Turned on my headset and it auto-connected and was able to play sound. Now, it’s not perfect. I still am getting stuttering and lag. :-\ But it does appear… Read more »

SuperMin
Admin
SuperMin

Other things that help a LOT are direct connections to the USB port (no hubs), using an USB extension cord to bring it closer to the user and of course, Microwaves and Fluorescent Lighting avoidance. 🙂

ashoke
Member
ashoke

I am a novice Ubuntu lover. My desktop is on Ubuntu 16.04.4 LTS only. A Sony MDR-ZX220BT headset is paired but no sound from computer. Presumably, this is what most people are reporting. I have tried several recipes/graphic tutorials without success. I downloaded 17.10 and 18.04 LTS. Try-installed the former. Got no luck. Same problem persists. Then the later one worked like magic. Everything got configured automatically. The sound setting screen is different. 🙂 I do not want to go for fresh install as I have many updated apps. It is said, the upgrade of Ubuntu 18.04.1 LTS may arrive… Read more »