Failed to set card profile to 'a2dp_sink' , help

I have seen this error and it is due to a bug with either pulseaudio or bluez. You may likely find that setting the audio profile to off, then disconnect from the headphones, reconnect to the headphones and then you may have no issues using A2DP. It appears that your script may do that but you may find pylover's a2dp.py python script will work for you

wget https://gist.githubusercontent.com/pylover/d68be364adac5f946887b85e6ed6e7ae/raw/d698974910bbb7d016ec0ad08c1bf41b4b524364/a2dp.py
alias headphones="a2dp.py 04:52:C7:0D:9E:13"

Then when you want to use your headphones, just type headphones


On Elementary OS Hera 5.1.7 (based on 18.04.4) using kernel 5.8.0-39 (necessary for hardware compatibility reasons), I was able to resolve this issue by

  1. installing pavucontrol and blueman and
  2. editing /etc/bluetooth/main.conf "MultiProfile=multiple" under "general" (see https://wiki.archlinux.org/index.php/Bluetooth_headset#A2DP_not_working_with_PulseAudio) change "AutoEnable=false" (not sure if that did anything)

Before this, I couldn't connect to bluetooth audio sinks, period, unless I used bluetoothctl. At that point, it would only connect to the duplex low quality sink (HSP/HFP) and not A2DP (high audio quality).

Now it appears to be able to work well enough in either mode, with mode-switching on the fly, however, with consistent errors:

[  994.225669] Bluetooth: hci0: urb 0000000085e83e50 submission failed (90)
[  994.225675] Bluetooth: hci0: sending frame failed (-90)
[  994.238145] Bluetooth: hci0: SCO packet for unknown connection handle 0
[  994.238153] Bluetooth: hci0: SCO packet for unknown connection handle 0
[  994.238155] Bluetooth: hci0: SCO packet for unknown connection handle 0
[  994.238157] Bluetooth: hci0: SCO packet for unknown connection handle 0

EDIT - please see warning from Sam Jaques below. This worked for me, but use at your own risk.

I've tried setting the profile to off, disconnecting and reconnecting the bluetooth device, but still could not switch to a2dp_sink. I finally found a working solution here on the Debian wiki

If you're using Gnome, Gnome Display Manager (GDM) 'captures' the A2DP sink on session start, which is why it's not available for the device to use. If you try to change the profile using the sound settings GUI, you'll notice that you can select A2DP Sink from the dropdown, but it simply switches back upon closing the dialogue. If you hit test speakers you'll notice it still only shows Mono.

The article has details but to summarise:

Create and add these lines to /var/lib/gdm3/.config/pulse/client.conf:

autospawn = no
daemon-binary = /bin/true

Change the file's owner and group:

sudo chown gdm:gdm /var/lib/gdm3/.config/pulse/client.conf

Then disable pulseaudio startup:

rm /var/lib/gdm3/.config/systemd/user/sockets.target.wants/pulseaudio.socket

add this to /etc/pulse/default.pa:

load-module module-switch-on-connect

Then restart.