Support for higher quality bluetooth A2DP audio codecs in sailfishos

SailfishOS should have support for additional higher quality bluetooth A2DP audio codecs. Currently (as of sfos v4.0) only the basic mandatory SBC codec is supported with bluetooth A2DP.

Optional A2DP codecs such as AAC, AptX, AptX HD, and LDAC allow using bigger bitrate and/or higher quality than the mandatory/default SBC codec.

sfos currently ships bluez v5.54, which in theory has the initial support for using and switching multiple bluetooth A2DP audio codecs, but it’d be good to upgrade to latest bluez version (v5.58+) where A2DP codecs functionality is known to work properly on desktop/laptop Linux, as there have been multiple related bugfixes since version 5.54.

Pulseaudio 15.0 will have support for multiple bluetooth A2DP codecs (when used with current bluez, and additional codecs are available). Currently pulseaudio 15.0 is still in development, and the final version hasn’t been released yet, but the multiple bluetooth A2DP codecs functionality is already merged and working.

Pulseaudio 15.0 also has support for higher quality bluetooth backchannel / microphone in HFP mode by using optional mSBC codec (also known as Wide Band Speech). mSBC allows using 16 kHz samplerate, which is much better quality than the 8 kHz samplerate with the default CVSD microphone codec.

Pulseaudio 15.0 also enables using multiple SBC codec profiles/bitpools in A2DP mode, allowing higher quality also with the mandatory SBC codec.

27 Likes

Related topics:

old tjc:

2 Likes

LDAC (Hi-Res Audio Wireless Certification) is one of the Main Reasons to buy a Sony Smartphone. I have several Sony Headphones and some of them are wireless (WH-1000XM3, WI-1000XM2) but also does my A/V Receiver support LDAC.

It bumps up the Bit-Rate from 320kbit/s to 990kbit/s and is the only Codec (beside LHDC) that supports AudioCD Quality with lossless compression.

I can use LDAC on my Linux Notebook without any issues and since Android 10, every Android Smartphone Supports LDAC due to the GPL License of the LDAC Encoder.

Everything i had to do to make it running on Linux was to install pulseaudio-modules-bt (which had libldac as an dependency) and thats it. Now i can play music using LDAC on all my devices.

So it shouldn’t be that complicated to implement that in SFOS, or?

8 Likes

PulseAudio 15.0-rc1 (14.99.1) has been released:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2021-May/032082.html

This is probably going to be the largest set of changes in a single release in a very long time. A non-comprehensive set of highlights include:

  • Support for more Bluetooth A2DP codecs, higher quality with SBC, and absolute volume
  • Native HFP implementation for better headset compatibility and call audio quality using the mSBC codec
4 Likes

Pulseaudio 15.0 has been released:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2021-July/032099.html

  • “Lots of Bluetooth features (more A2DP codecs, native HFP support with mSBC for better audio quality, AVRCP Absolute Volume)”
  • Support for multiple bluetooth A2DP codecs: LDAC, AptX, AptX HD, SBC XQ, etc
  • Support for higher quality microphone/backchannel via mSBC / Wide Band Speech (WBS).
8 Likes

And how does this (PulseAudio 15) help me, actually, if I want improved audio from my SFOS to my BT headphones (Aptx-HD)?

I could use FLAC rather than MP3 insane and survive with less music. Higher fidelity would be nice. I can use a 3.5 on my headphones, but sometimes that’s inconvenient

1 Like

The last uplift of Pulseaudio is coming up on one year old, so not terrible, but due another one.
And at least from a casual observer it looks to be in good shape for uplifting even though it has some adaptations on top.
Shameless ping: @jusa
I really appreciate good quality audio, so i feel a bit silly using my fancy IEMs currently.

@DrDweeb It is just that, a codec question. With the current situation it wouldn’t matter if you use FLAC when the connection to the headphones is compressed with a pretty big loss in quality. I think it is even technically worse than high-bitrate mp3.

4 Likes

you may try new gstreamer 1.20 with LDAC and aptx support Gstreamer 1.20.0 (JollaPhone & X & XA2) | OpenRepos.net — Community Repository System in combination with gstreamer-bluez module gstreamer1.0-plugins-bad-bluez5 (X XA2 X10) | OpenRepos.net — Community Repository System

disadvantage is that you will have to use gstreamer at commandline to establish a connection. Pulseaudio is not involved…

3 Likes

Maybe interesting to some : it is possible to significantly increase SBC bitrate. This was explored some time ago (an interesting explanation Bluetooth stack modifications to improve audio quality on headphones without AAC, aptX, or LDAC codecs / Хабр) and led to SBC XQ which has been integrated in LineageOS, and more recently in pulseaudio 15.

Since Sailfish OS is still at pulsaudio 14, I applied a patch implementing just that (Files · SBC-XQ · JP Guillemin / pulseaudio · GitLab) on the pulseaudio source tree from Sailfish repository and rebuilt it (for 4.3.0.12 / 64 bits).

I don’t know yet how to package that properly for openrepos, but applied it successfully on my phone :

  • the only file which needs to be replaced is /usr/lib64/pulse-14.2/modules/libbluez5-util.so
  • the bitrate negotiated before / after application can be checked with (as defaultuser) “pacmd set-log-target file:/home/defaultuser/Downloads/pulse.log”, “pacmd set-log-level 4”, connect your headset then “grep a2dp-codec-sbc /home/defaultuser/Downloads/pulse.log” and calculate the bitrate with the formula on habr.com above
  • with my phone / headsets I get a 452kbps bitrate instead of the nominal 328kbps of SBC
  • my ears tell me that the sound is better than what I get with SBC and aptx, probably on par with aptx HD ; treeble seems to be better giving more space to the sound
  • definitly needs confirmation by other listening tests
9 Likes

Great achievement, thanks for letting us know.

Since the bitrate is increased, does that have any effect on the supported range between phone and headset?

Thanks,

I did not test that extensively, but with the two headsets I use the most, I didn’t find any difference (and one of them has quite a low range). I had a some occurrences of sound degradation with my hifi which were noticeable enough. The sound quality gradually decreased until I disconnected / reconnected. Maybe two times out of the ten.

What you are suggesting is great! :slight_smile:

But…

Please keep in mind that the amount of devices that use anything else but A2DP + SBC and perhaps AAC too is VERY LOW :frowning:

For example :

Try to find a device that uses AptX or AptX HD and you are suddenly trying to find a needle in a haystack! :confused:

You can find the official list of aptx enabled products from here: Qualcomm® aptX™ Automotive | Bluetooth® Car Stereos & Receivers , it allows you to search/filter by different aptx codecs/versions.

also there’s some non-certified but working devices available aswell, mostly from china (as the original aptx related patents have already expired).

Bump … I posted about this somewhere as well.

PulseAudio 16.0 has been released, release notes: 16.0

4 Likes

Dear Schrdlu,
how can get this new libbluez5-util.so?

You can get it here : Download files - Filemail

64 bit version that works on my 10 ii and 10 iii on sfos 4.4.0.64. didn’t check with 4.4.0.72.

You should rename the original libbluez5-util.so to something like libbluez5-util.so.old before copying the file.

Don’t forget to set owner / group and permissions like the original.

I will be interested by your results.

4 Likes

Thank you, very much. I will try this on my XZ2 Compact with SFOS 4.4.0.58

1 Like

Dear Schrdlu, thank you so much :pray:. I replaced libbluez with yours *.so, rebooted sailfish device. After that connect Marshall Major 3 and quality of sound very good. I do not listen on Marshall before replace lib, but with comparison with same track on notebook quality as on wire connect. (device - Sony XZ2 Compact with Rings port, SFOS 4.4.0.58 )

2 Likes

Dear Schrdlu, I upgraded the system to version 4.4.0.72. Your fix works fine on the new system. Thank you very much.

2 Likes