15

I have paired my Bluetooth headset with my Ubuntu 12.04 laptop with a Bluetooth chip inside:

lsusb | grep Bluetooth

Bus 003 Device 003: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for Bluetooth

The device has been paired, and with the help of blueman, I've connected it to PulseAudio as a sink. Audio does come across in A2DP mode, but is terribly choppy and skips to the point of being not much better than nothing.

I read around and saw that there was a fix involving adjusting the nice priority of the PulseAudio server. Since by default, PulseAudio runs on a per-user basis, I added the following to my /etc/security/limits.conf:

*       hard    rtpio   0
*       soft    rtpio   0
@audio  hard    rtpio   20
@audio  soft    rtpio   20
pulse   hard    rtpio   20
pulse   soft    rtpio   20

I then added myself to the audio group to be able to schedule priority for the pulseaudio process. It seems that pulseaudio is now running with a priority of -11:

ps -eo pri,ni,cmd | grep [p]ulse

30 -11 /usr/bin/pulseaudio --start --log-target=syslog

This should mean that PulseAudio is running with a priority of -11, which is good.

However, even after restarting, I still get the terrible choppy audio.

How should I proceed? I'm trying to make this Bluetooth headset I purchased usable.

Note: I've tried pairing this device with an Android tablet right next to my laptop and it works fine, so it's not wireless congestion, it seems to be directly correlated to Linux somehow.

22

Edit the ALSA configuration file

sudo gedit /etc/modprobe.d/alsa-base.conf

Add the line

options snd-hda-intel model=generic

to the end of the file, and reboot.

| improve this answer | |
  • 1
    This worked wonderfully for my BOSE quiet comfort 35 II speakers (ubuntu 18.04) – Victor Parmar Jun 26 '18 at 12:39
  • This simple fix also worked for me after a lot of searching. Ubuntu 18.10, bluetooth earphones (promate trueBlue). – Francesco Napolitano Nov 20 '18 at 14:15
  • Created an account to mention that this solved my problems too (QC35II). An explanation would be helpful; but either way, you are a life saver – Sam Jan 3 '19 at 10:34
  • I see about 95% less choppiness with this fix with QC35II on Debian 9 testing, kernel 4.18.20-2. – Andrey Portnoy Jan 5 '19 at 7:52
  • 4
    at the end after editing this file you don't need to restart, just run sudo service bluetooth restart – Dinuka Salwathura Jan 13 '19 at 3:49
16

As none of the other answers worked on my system (Ubuntu 18.04 LTS on a 2012 MacBook Air), I found my solution on the german ubuntuusers wiki. English summary of the german instructions:

The choppy output might be caused by the A2DP implementation, and how it buffers sound before encoding it. For me, changing this buffer's size solved the choppy sound problem. You need to perform three steps:

  1. Find necessary info about the bluetooth device (while it is connected!)

    pactl list | grep -Pzo '.*bluez_card(.*\n)*'
    

    The output should be something like

    Name: bluez_card.28_11_A5_84_B6_F9
    Driver: module-bluez5-device.c
    ...
    Ports:
    speaker-output: Speaker (priority: 0, latency offset: 0 usec, available)
        Part of profile(s): a2dp_sink, headset_head_unit
    speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec, not available)
        Part of profile(s): headset_head_unit
    

    We see that the buffers have currently 0 latency. In the next step, you will need the NAME and PORT of your output. In this example, these are bluez_card.28_11_A5_84_B6_F9 and speaker-output, respectively.

  2. Set the buffer size (latency) of your card to a suitable value with this command pattern:

    pactl set-port-latency-offset <NAME> <PORT> <BUFFER_SIZE_MICROSECONDS> 
    

    The latency unit of the following command is microseconds, so I'm using a 50 millisecond buffer for my command here:

    pactl set-port-latency-offset bluez_card.28_11_A5_84_B6_F9 speaker-output 50000 
    
  3. Restart your bluetooth service to apply your change

    sudo service bluetooth restart
    

As there is usually no documentation about this, you may have to experiment with higher or lower buffer values.

| improve this answer | |
  • 1
    You deserve more upvotes! I would like to mention that 45000 works well for the Macbook Air (early 2014) and Bose QC35 – Ole Aldric Mar 13 at 11:42
  • This is correct, thank you – jhtong Apr 19 at 3:11
  • Still stuttering for me :( (Manjaro) – Lucas Bustamante May 11 at 14:38
  • Which latencies did you try? – Chris_128 May 12 at 9:35
  • 1
    a much smaller value worked most of the time, but I had to crank it up to 64448 to get rid of skips when doing stuff like inspecting elements in chrome and changing styles. – Nick May 15 at 21:13
4

Chris_128 answer worked for me but for newbies I'll add a bit detail.

For the NAME and PORT for the command below:

pactl set-port-latency-offset NAME PORT 50000 

You will get it after you have result from typing:

pactl list | grep -Pzo '.*bluez_card(.*\n)*'


Name: bluez_card.5C_FB_7C_0D_0F_EE
Driver: module-bluez5-device.c
Owner Module: 28
Properties:
    ...
Profiles:
    headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
    off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
    headset-output: Headset (priority: 0, latency offset: 0 usec, available)
        Part of profile(s): headset_head_unit, a2dp_sink
    headset-input: Headset (priority: 0, latency offset: 0 usec)
        Part of profile(s): headset_head_unit

The NAME will be "bluez_card.5C_FB_7C_0D_0F_EE" and the PORT will be "headset-output"

So for my case my command is

"pactl set-port-latency-offset bluez_card.5C_FB_7C_0D_0F_EE headset-output 50000"

Restart your bluetooth service

sudo service bluetooth restart
| improve this answer | |
3

The fix worked for me, although I did find that I had to REM the line before it. See below:

# Keep snd-usb-audio from beeing loaded as first soundcard  
# options snd-usb-audio index=-2  <-REM this line if it doesn't work at first  
options snd-hda-intel model=generic
| improve this answer | |
2

Had the same issue with Ubuntu 18.04 running as dual boot in MacBook Mini. Tried changing the ALSA configuration as mentioned by @ConfirmAndCreateThisAccount.

But it didn't work.

So i installed Blueman using the below command

sudo apt-get install blueman

Then i disconnected the bluetooth device from the system bluetooth settings & re-paired using Blueman. Now everything is fine. Even the Play/Pause controls work.

| improve this answer | |
1

You can open the search bar (CTRL-D in unity, Windows-Key in Gnome) type in "Pulse" or "Volume". Open the GUI tool "Pulseaudio Volume Control", its icon looks like knob or gauge.

There you can select your Bluetooth speaker. Click on Advanced, set the Latency value just like proposed in the other answers . 45 ms or 50 ms seems to work for them, but I haven't found a good value that works for me.

A screenshot is attached. My Bluetooth Speaker is called SRS-BTX300. You don't need to restart bluetooth after changing the latency value.

enter image description here

| improve this answer | |
  • This did the trick! – daviewales Jun 28 at 1:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.