7

I'm using my bluetooth headphones with ubuntu desktop, which has bluetooth dongle. Right now I can connect headphones every time (wasn't so at the start, needed to repair them about every time I wanted to connect). So now it connects, but doesn't output any sound. Sometimes restarting pulse audio helps, sometimes it doesn't, I'm very tired of it and I would like to dig to the root of a problem.

pacmd set-card-profile $(pacmd list-cards | grep -Pzo '(?<=index: )(\d+\n)(?=.*bluez_card)') a2dp_sink;

This gives me Failed to set card profile to 'a2dp_sink'. Help me to dig further.

#! /usr/bin/env zsh
pacmd set-card-profile $(pacmd list-cards | grep -Pzo '(?<=index: )(\d+\n)(?=.*bluez_card)') off;
echo -e 'disconnect 04:52:C7:0D:9E:13\n quit'|bluetoothctl
sleep 5
echo -e 'connect 04:52:C7:0D:9E:13\n quit'|bluetoothctl
sleep 5
pacmd set-card-profile $(pacmd list-cards | grep -Pzo '(?<=index: )(\d+\n)(?=.*bluez_card)') a2dp_sink;

This isn't helping.

1

4 Answers 4

9

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

4
  • 2
    It's not working for me
    – lamino
    Jun 13, 2017 at 4:44
  • 2
    This py script worked like a charm for me.. Apr 27, 2018 at 20:12
  • Thank you so much! Oct 8, 2019 at 8:29
  • I tried that. after disconnecting the headphones they will not show up as connactable again.. :(
    – mondjunge
    Mar 24, 2022 at 9:50
2

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
2
  • Solved it for me under Alpine Linux Edge (v3.15 with Kernel 5.11.22-r1). Dec 14, 2021 at 4:16
  • Worked for me on Debian 6 Feb 25 at 22:52
1

The way I fixed it is by doing away with gdm entirely, since it's so jealous of my A2DP sink and it doesn't look like anyone is fixing it. I consider it broken.

sudo apt-get -y install slick-greeter

And then select "lightdm". Good riddance.

1

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.

2
  • On Ubuntu 18.04.5 this broke pulseaudio altogether and I had to reinstall it to get any audio back.
    – Sam Jaques
    Apr 15, 2021 at 19:05
  • @Sam Jaques yikes, I'm sorry to hear that. Feel free to downvote as justified. I'm adding a warning.
    – Casey L
    Apr 15, 2021 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .