arkq/bluez-alsa

Can't get the A2DP profile to use LDAC codec

dstagger opened this issue · 11 comments

Problem

I can't get bluealsa to use the LDAC codec for my Sony WF-1000XM5 earbuds. Only SBC seems to be working.
I've installed from the source using ../configure --enable-ldac --enable-systemd, and had prebuilt ldacBT from the source as well, before compiling bluealsa.

Reproduction steps

$ bluealsa-aplay -L
bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=a2dp,SRV=org.bluealsa
    WF-1000XM5, trusted audio-headset, playback
    A2DP (SBC): S16_LE 2 channels 48000 Hz

Setup

  • Ubuntu 22.04 LTS Server
  • the version of BlueALSA (v4.2.0-5-g9d73103)
  • the version of BlueZ (5.64)
  • the version of ALSA (1.2.6)
  • if self-built from source, please state the branch and commit
    (9d73103 (HEAD -> master, origin/master, origin/HEAD) Create A2DP D-Bus path based on codec object), and the used configure options: --enable-ldac, --enable-ldac

Additional context

$ cat .asoundrc 
defaults.bluealsa.interface "org.bluealsa"
defaults.bluealsa.device "XX:XX:XX:XX:XX:XX" # change this to your Bluetooth device address
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.codec "ldac"
defaults.bluealsa.delay 10000
$ journalctl -u bluealsa
May 20 11:23:01 server systemd[1]: Starting BlueALSA service...
May 20 11:23:01 server bluealsa[726]: Couldn't get HCI version: Network is down
May 20 11:23:01 server systemd[1]: Started BlueALSA service.
May 20 11:35:40 server bluealsa[726]: Couldn't set A2DP configuration: Extra A2DP endpoint not available
May 20 11:35:40 server bluealsa[726]: Couldn't select codec: LDAC: Input/output error
May 20 11:40:52 server bluealsa[726]: Couldn't set A2DP configuration: Extra A2DP endpoint not available
May 20 11:40:52 server bluealsa[726]: Couldn't select codec: LDAC: Input/output error
arkq commented

Could you share the output from bluealsa-cli info <pcm_path> ?

$ bluealsa-cli info /org/bluealsa/hci0/dev_XX_XX_XX_XX_XX_XX/a2dpsrc/sink
Device: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX
Sequence: 0
Transport: A2DP-source
Mode: sink
Running: false
Format: S16_LE
Channels: 2
Sampling: 44100 Hz
Available codecs: SBC
Selected codec: SBC
Delay: 190.0 ms
DelayAdjustment: 0.0 ms
SoftVolume: true
Volume: L: 127 R: 127
Muted: L: false R: false
arkq commented

Available codecs: SBC

It seems that your end-device does not support LDAC. Or LDAC was not enabled in bluealsa service. It has to be enabled on command line when running service: bluealsa -c ldac

EDIT:
Make sure that HD audio is enabled in your earbuds setup (via smartphone app). By default Sony enables connection quality.

It seems that your end-device does not support LDAC

This headset supports LDAC 100%

It has to be enabled on command line when running service: bluealsa -c ldac

$ bluealsa -p a2dp-source -c ldac
bluealsa: E: Couldn't acquire D-Bus name. Please check D-Bus configuration. Requested name: org.bluealsa

Make sure that HD audio is enabled in your earbuds setup (via smartphone app). By default Sony enables connection quality.

Already setup like that and LDAC works perfectly in when connected to Windows.

arkq commented

bluealsa: E: Couldn't acquire D-Bus name. Please check D-Bus configuration. Requested name: org.bluealsa

I assume that you are running bluealsa as a system service. In such case you have to add this -c ldac option to bluealsa systemd file. If you are compiling this project from source, you can use --with-systemdbluealsaargs in the configuration step (or use sudo systemctl edit bluealsa). The default is --with-systemdbluealsaargs="-S -p a2dp-source -p a2dp-sink", so modify it as: --with-systemdbluealsaargs="-S -p a2dp-source -p a2dp-sink -c ldac"

And one last thing to confirm. Check whether LDAC is available as A2DP source codec. See output from bluealsa -h. There should be something like:

...
Available BT audio codecs:
  a2dp-source:  SBC, LDAC
  a2dp-sink:    SBC, LDAC
...

Yes that's the fix. Thank you!
However, LDAC works only when I pass -p a2dp-source as parameter and not both -p a2dp-source and -p a2dp-sink. Is it because LDAC isn't available as a2dp-sink codec in my case?

One more related question: the file /etc/dbus-1/system.d/bluealsa.conf wasn't created during the compile > make > install process, and I had to manually create it by copying from elsewhere. Is there a flag that I missed in the configure step?

arkq commented

However, LDAC works only when I pass -p a2dp-source as parameter and not both -p a2dp-source and -p a2dp-sink. Is it because LDAC isn't available as a2dp-sink codec in my case?

To be honest, I'm not sure. I've just checked and it seems that everything should work properly in that case (if you are using bluealsa as A2DP source). What is the outcome when both a2dp-source and a2dp-sink are specified? Earbuds does not connect with your host, or maybe they connect but the audio does not work (with LDAC)?

One more related question: the file /etc/dbus-1/system.d/bluealsa.conf wasn't created

If you are installing bluez-alsa from source, it should be in /usr/share/dbus-1/system.d/ by default. D-Bus should read it from there. The /etc/dbus-1 is for distribution provided config (override for upstream config).

If you are installing bluez-alsa from source, it should be in /usr/share/dbus-1/system.d/ by default

I've just checked the manual page and the troubleshooting guide and they are both still saying /etc/dbus-1/system.d, so they both need updating. I can do that if you wish.

arkq commented

I've just checked the manual page and the troubleshooting guide and they are both still saying /etc/dbus-1/system.d, so they both need updating. I can do that if you wish.

To be honest I'm not sure what manual and troubleshooting guide should say about that. For sure, installation from source should be based on upstream. However, consider scenario where bluez-alsa is packaged by distribution and in such case override config is stored in /etc. Then, modifying config in /usr will do nothing... So, I'm all up to your gut feelings about that :D If you think that it will be better to update docs, then please do that.

Earbuds does not connect with your host, or maybe they connect but the audio does not work (with LDAC)?

Earbuds connect as usual with the bluez stack but only SBC is available as the codec.

D-Bus should read it from there

It does indeed as I deleted bluealsa.conf from /etc/dbus-1/system.d and everything is still working as before.