29

I have a nice bluetooth audio receiver connect to my HiFi stereo, and I used to be able to connect it in 14.04 as a A2DP sink with nice quality.

After upgrading to 16.04, the device connects only as headset, and when trying to switch it in A2DP mode, I have this error in my syslog:

May 21 11:35:50 RRyS pulseaudio[6159]: [pulseaudio] module-bluez5-device.c: Refused to switch profile to a2dp_sink: Not connected

and the quality of audio is abismal. How can I fix it?

  • Hope this is useful to somebody. I have lost 3 hours digging into it... I love upgrades! ;-) – Rmano May 21 '16 at 10:34
38

What works for me is to connect the bluetooth device, switch to HSP/HFP mode, disconnect, reconnect and then switch to A2DP mode.

  • 4
    Same here. However, it is not supposed to be this way and it used to work properly in previous version. – eldad-a Sep 22 '16 at 20:10
  • For me too, that worked. But a real big pain in the a** for something that was working (nearly) flawlessly in 15.10 and before. – Dolanor Oct 14 '16 at 10:30
  • Oh believe me, I agree. it's a huge pain. The only distro I've found that handles BT correctly out of the box nowadays is Solus OS. – rmfought Nov 2 '16 at 23:44
  • 2
    This is super weird but it worked! – ArcaneDominion May 9 '17 at 17:45
  • 1
    Holy crap. Didn't expect this to work, but it did. – Parth Thakkar Dec 19 '17 at 12:49
35

There are several bugs opened about this, check for example this one (started in 15.05) and this other one, quite older; the causes in general are not well understood.

Before starting modifying system files, you can also check Bluetooth speaker no sound in Ubuntu 16.04 (seems a different bug) and A2DP bluetooth doesn't work on 16.04 (solved in comments by a kernel upgrade).

The fix that worked for me is the following --- thanks to user RobertFM in launchpad and SimFox3 in Arch forums. All the following instructions must be executed from a root shell (sudo -i). Take care and triple check.

  1. First of all, make a backup of these files (you never know):

    cp /etc/bluetooth/audio.conf /etc/bluetooth/audio.conf.bak
    cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
    cp /usr/bin/start-pulseaudio-x11 /usr/bin/start-pulseaudio-x11.bak
    
  2. Edit /etc/bluetooth/audio.conf and make it similar to this one:

    # Configuration file for the audio service
    # This section contains options which are not specific to any
    # particular interface
    [General]
    Enable=Gateway,Source
    
    # Switch to master role for incoming connections (defaults to true)
    Master=true
    
    # If we want to disable support for specific services
    # Defaults to supporting all implemented services
    #Disable=Gateway,Source,Socket
    Disable=Socket
    
    # SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
    # Defaults to HCI
    #SCORouting=HCI
    
    # Automatically connect both A2DP and HFP/HSP profiles for incoming
    # connections. Some headsets that support both profiles will only connect the
    # other one automatically so the default setting of true is usually a good
    # idea.
    AutoConnect=true
    
    # Headset interface specific options (i.e. options which affect how the audio
    # service interacts with remote headset devices)
    [Headset]
    
    # Set to true to support HFP, false means only HSP is supported
    # Defaults to true
    HFP=true
    
    # Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
    MaxConnected=2
    
    # Set to true to enable use of fast connectable mode (faster page scanning)
    # for HFP when incoming call starts. Default settings are restored after
    # call is answered or rejected. Page scan interval is much shorter and page
    # scan type changed to interlaced. Such allows faster connection initiated
    # by a headset.
    FastConnectable=true
    
    # Just an example of potential config options for the other interfaces
    #[A2DP]
    #SBCSources=1
    #MPEG12Sources=0
    
  3. Edit /etc/pulse/default.pa and comment out the line

    #load-module module-bluetooth-discover
    

    (you really only need to add the # at the start)

  4. Edit /usr/bin/start-pulseaudio-x11 and add the line /usr/bin/pactl load-module module-bluetooth-discover after the loading of the module module-x11-xsmp; in practice you should edit the file near the end to have a stanza like

    if [ x"$SESSION_MANAGER" != x ] ; then
        /usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
        # add this line here:
        /usr/bin/pactl load-module module-bluetooth-discover
    fi
    
  5. Reboot.

    Now you should be able to set your device to A2DP and enjoy high quality music:

    Sound settings

    Notice that sometime you need to Disconnect and Reconnect your device to re-enable A2DP:

    Bluetooth devices

    ...yes, it's a can of bugs. But when it works it works beautifully.

  6. Troubles after reboot

    After all of this, sometime the trick seems to work just only after the next reboot. In such a case, try to follow rmfought's answer:

    What works for me is to connect the bluetooth device, switch to HSP/HFP mode, disconnect, reconnect and then switch to A2DP mode.

    ...works for me too (again, sometime). I had to even un-pair a re-pair the dongle once.

  7. If it still doesn't work...

    If this also isn't working for you, you can try with this script --- its author is keeping it up-to-date.

  • 5
    audio.conf is not present in ubuntu 16.04, only main.conf, will that work? – Joakim Koed May 31 '16 at 16:30
  • 2
    @JoakimKoed --- you're right, I checked --- I had a audio.conf-remove probably remnant from the upgrade. I simply recreated it --- so now I am in doubt, maybe just points 3 and 4 are necesssary? – Rmano May 31 '16 at 16:38
  • 1
    Steps 3 & 4 did not fix for me, and I recreated audio.conf as per the above and no fix. Deleting the bluetooth device and repairing fixes, but doing that every time you want to use bluetooth audio is not feasible. – Thomas Carlisle Jun 15 '16 at 2:08
  • @ThomasCarlisle sorry to hear that - here it worked (no need to re-associating) after the first time. Must be a different thing... – Rmano Jun 15 '16 at 6:07
  • 1
    Brilliant! It does the trick with me! I suggest you add a reference to it in your answer, as all together seems to give a fully working solution to the problem. Cheers! – romanovzky Nov 8 '16 at 9:24
5

This is not necessarily a solution for those who need the mic, but this worked in Ubuntu 16.04 for me:

sudo nano /etc/bluetooth/audio.conf

And then add Disable=Headset under [General].

[General]
Disable=Headset

And restart the bluetooth service

sudo service bluetooth restart

And all the creds to this guy: https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/

  • Unluckily, didn't work out for me. My bluetooth dock icon is greyed out… Maybe it's the driver/module? XPS 13 9350 and ubuntu 16.04. – Dolanor Oct 16 '16 at 7:55
  • @Dolanor Not sure wether this is still a problem, but a if the dock icon is greyed out, it most likely means that your bluetooth-adapter is softblocked. Try rfkill unblock bluetooth and maybe even bluetoothctl and then power on (in the bluetoothctl-CLI). – FMaz Mar 21 '17 at 14:33
  • This worked in my case zorinos 12 – FDisk Mar 28 '18 at 13:51
  • On Ubuntu 18, there is no /etc/bluetooth/audio.conf file. I added Disable=Headset to /etc/bluetooth/main.conf, restarted the service, reconnected my headphones, but the audio profile was by default off. Not sure this worked? – Dan Dascalescu Jun 22 at 4:50

protected by Community Sep 15 '16 at 9:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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