Support for higher quality bluetooth A2DP audio codecs in sailfishos

Well, at least it can be made to build… now how to test?

1 Like

If you can send me a build I’ll test it out.

2 Likes

I managed to get my spare phone to start updating. So soon i’ll be able to test on something that doesn’t need to survive.

1 Like

Sooo… results are very unclear.

I installed immediately to my C2 and i could never get any sound over Bluetooth with neither of my nicer headphones. Then i reverted - and it was exactly the same.

But at least it wasn’t boot-looping and the C2 can be a bit temperamental, so i guess i could test with my daily driver 10 III. My daily driver bone conduction headphones still worked - but neither of the nicer ones.
It doesn’t appear to be my build breaking this, since that stays non-working after i revert… but i guess it cannot be ruled out since i technically didn’t test between updating to 5.1 and now.

The only observable difference is that the list-codecs command from above works on my build and not on the stock one.
Output (line-breaks for readbility):

[{"name":"sbc","description":"SBC"},
 {"name":"sbc_xq_453","description":"SBC XQ 453kbps"},
 {"name":"sbc_xq_512","description":"SBC XQ 512kbps"},
 {"name":"sbc_xq_552","description":"SBC XQ 552kbps"}]

So since i can’t compare, i can’t tell if that’s an improvement. Edit: now it works again all of a sudden - the output is exactly the same. I’d also not expect these headphones to have very fancy codecs.

Bluetooth has been very moody for me too on my 10 II since the update. I have several devices that support both various incarnations of AptX and LDAC and my offer to test still stands.

1 Like

If and when it breaks you may keep the pieces.

1 Like

Sorry it took so long. It’s not working and I had to do some detective work. First off, you don’t need to replace all of pulseaudio, just /usr/lib64/pulse-17.0/modules/libbluez5-util.so. Second, there’s neither AptX nor LDAC support in gstreamer, which is why it’s not showing up for me at least. Both should be in gst-plugins-bad but they depend on libfreeaptx/libopenaptx and libldacBT-enc respectively. The resultant libraries would be /usr/lib64/gstreamer-1.0/libgstopenaptx.so and libgstldac.so which are conspicuously missing.

These are the libs gentoo would use:

So I guess we’re gonna need those packaged first, and then rebuild gstreamer1.0-plugins-bad

2 Likes

Perhaps - but i get an rpm when i build and i don’t want to manually mess with system libraries unless i have to.

That would be how that goes, yes. Supposedly stealing rpm specs from Fedora is the way to go.

1 Like

Luckily for us, they have both :slight_smile:

Edit: if I ask nicely, can you build them for me with? I don’t have a build env anymore and I imagine it’ll be a pain to get working since I’m down to a single workstation and it’s a very minimal musl system.

For gst-plugins-bad, -Dldac=disabled and -Dopenaptx=disabled would need to be changed but then I’m fairly confident that it should work.

Neither of those build as-is and would need some adaptation. I don’t think i have time to dig deeper in that right now.

Well that’s unfortunate. Thank you for trying anyway. I’ll see if I can rig something up later.

1 Like

What about the SBC-XQ codecs? Are these available?

Works as long as you switch manually. Scroll up in the thread to see how.

Now, I managed to step through why I couldn’t switch to mSBC when in HSP mode. Turns out, you’re not allowed to switch yourself. Long story short, load-module module-bluez5-discover headset=droid enable_msbc=false in /etc/pulse/default_sailfish.pa was preventing it from automatically choosing mSBC. So I set it to true and now it switches to mSBC instead of CVSD when in HSP mode. The only problem is that now there’s no audio during voice calls (tested it with VoLTE and GSM). I’m not well versed enough in the telephony stack to know where it’s going wrong. I would have assumed that PulseAudio would transcode to whatever the target was. I’ve read through the documentation but I feel like I’ve hit a dead end. Since it’s been explicitly disabled I’m guessing there’s a hardcoded CVSD assumption somewhere; I just can’t find it.

I’m hoping someone here knows more than me about this. I was searching for wherever the transcoding to AMR-WB happens to see if it held some clues.

2 Likes

Cool beans. Thanks for the explanation.

It would be nice if one of the next major changes for SailfishOS would be replace PulseAudio with PipeWire.

This would bring much better Bluetooth audio (especially with modern codecs), low-latency audio, screen sharing/casting improvements, and future audio hardware support. And it has already started to become the standard Linux distros and would make Sailfish feel more current.

6 Likes

Replace PulseAudio with PipeWire

Feel free to experiment:

Any contributions are very welcome - especially ports of the SFOS-specific PA plugins (which nullify PW’s claims to be a drop-in replacement for PA).

It would also be great if you could write PW audio and video backends to interface with droidmedia.

Also wireplumber scripts to do all the dynamic device adding, corking and removing, and interfacing with profiled and mce, would be needed.

All this is abit off-topic though, sorry for bringing it up.

12 Likes

Perhaps we could get closer to the middle by getting an alternative gst-plugins-bad compiling on chum? I have to admit I’ve been ignoring this since I’m a wired guy, but I could try to put some time in.

2 Likes

@nephros you beautiful bastard you already packaged freeaptx and ldacBT

if @poetaster or @attah wants to run a build of gst-plugins-bad with -Dldac=enabled -Dopenaptx=enabled then we’re there for A2DP.

(as expected, I cannot run the SailfishOS SDK on my system, but I’m looking at alternatives)

5 Likes

My work laptop is broken so I can try to put up a gst-plugins-bad build.

Watch this space: Project home:nephros:devel:gst-bluetooth Status Monitor - SailfishOS Open Build Service

This enables fdkaac, lc3, aptx, and ldac.

OK, building is done, @zhasha, @poetaster please test :slight_smile:

3 Likes

It works :slight_smile:

And for everyone else who wants to give this a go, you need

  1. ssu ar gst-bluetooth https://repo.sailfishos.org/obs/home:/nephros:/devel:/gst-bluetooth/sailfish_latest_aarch64/
    
    pkcon refresh
    
    pkcon update gstreamer1.0-plugins-bad
    
  2. Attah’s build of pulseaudio with gstreamer-bluez5 enabled, however all you need from the rpm is /usr/lib64/pulse-17.0/modules/libbluez5-util.so
    Edit, somehow managed to forget to link it: Release test1 · attah/sailfish-pulseaudio · GitHub

Now, there’s still the matter of mSBC not working during phone calls. I cannot figure out where it’s going wrong. ofono supports mSBC (explicitly), PulseAudio supports mSBC, and they even have a little handshake where support is declared and accepted by both. There doesn’t seem to be anything in the sailfish_ plugins to ofono that should break it. Can someone familiar with audio routing in the telephony stack point me in the right direction?

5 Likes