yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] cloneman1:
Ironically a lot of expensive proprietary headphones come from the apple store and don't support aptX or LDAC. Having SBC XQ would allow, for example, Bose headphones that only support regular SBC and AAC to sound better on Android. If anything it would increase sales of expensive headphones.

It's not a business decision, it's a stupidity decision, as has plagued bluetooth audio for years. The "open standard" which is obscenely hard to tweak without root, and then even with root, there's nothing available for Windows, Mac OS, or iOS. The only platforms where we have some amount of control is Linux and Android, and even then, only via obscure projects like this one.

Perhaps someday avantree will get onboard with their hardware bluetooth dongles. Although, their focus is aptX because of latency reasons. Even without aptX-LL headphones, regular aptX has decently good latency with a dedicated hardware dongle.
[Android Software/Hacking General [Developers Only]] klaberte:
Yes, this looks perfect. The first code block is just the capabilities of the receiver, in this case, your headphones. This response, to the "get capabilities" is unremarkable. Just about any compliant audio sink would report the same, as these modes are required by the SBC standard.

However, the second block is where it matters. It is saying that you did get dual-channel in the final configuration, and as such you have triggered ValdikSS' configuration. The only other thing to check is what actual bitpool is being used, since it can legally be set anywhere between 2 and 53. If you have the bluetooth log, try searching for packets with the SBC protocol.

---------- Post added at 12:39 PM ---------- Previous post was at 11:58 AM ----------

Also, I am not ROM cooker, but I am willing to learn. Could you give a bit more detail how you were able to make these changes to your Android device?
[Android Software/Hacking General [Developers Only]] ValdikSS:
You should check SBC audio packet data to determine real bitpool value, but at least from your dump it's clear that Dual Channel was negotiated.
[Android Software/Hacking General [Developers Only]] gorman42:
Question: to try this out I've installed crDRoid 5 on my Nexus 6P. Where am I supposed to activate SBC XQ?
[Android Software/Hacking General [Developers Only]] klaberte:
Go to Bluetooth settings, connect to your preferred device, press the gear next to the name of the connected bluetooth device (its settings). There in the settings should be a set of on/off switches, one of which should be the HD option. Enable there.

If you see other permissions switches, but not an HD switch, then that device likely won't work, e.g. it doesn't support dual_channel, even if it reports it does.
[Android Software/Hacking General [Developers Only]] keyap:
Thanks both.

Probably best to see if the OP wants to chime in. I spent ages 'experimenting' and still don't think I've got it right as the bitpool is not where it should be!

Also, the Vistas sometime don't work quite as they should and, because they're quite new, I'm not yet sure if that's a result of the modded file or something else?
[Android Software/Hacking General [Developers Only]] joedajoester:
Is this possible to use on stock with a pixel 3a?
[Android Software/Hacking General [Developers Only]] kamilchno:
I try the music play on JBL Bar 3.1 with the "HD sound: SBC" codec (Xperia Z3C, Lineage 16) but the sound is distorted. From post

@grandgreed shows that my soundbar works with a maximum of 482 kbps. How to edit the bluetooth library to reduce the sound to 482 kbps?

Connection:
bc:6e:64:bc:ad:2b (Xperia Z3 Compact) → 88:d0:39:07:20:2f (JBL Bar 3.1)

Supported codecs:
Audio SBC (16000 32000 44100 48000 | Mono DualChannel Stereo JointStereo | block: 4 8 12 16 | subbands: 4 8 | allocation: SNR Loudness | bitpool: 2..53)

Used for audio:
Audio SBC (44100 | JointStereo | block: 16 | subbands: 8 | allocation: Loudness | bitpool: 2..53)
Audio SBC (44100 | DualChannel | block: 16 | subbands: 8 | allocation: Loudness | bitpool: 2..53)

Latest SBC Bitpool value: 38
[Android Software/Hacking General [Developers Only]] zyhk:
SBC Bitpool value 38 means your soundbar works at 452kbps bitrate. I think your problem

is caused by DRC. Edit /vendor/etc/audio_policy_configuration.xml to disable DRC unless your ROM is GSI. (Lineageos 16.0 GSI has a bug that cannot disable DRC on bluetooth audio output.)
[Android Software/Hacking General [Developers Only]] jamesm113:
Looks like this issue is getting some traction in Google's issue tracker: https://issuetracker.google.com/issues/144517406

Perhaps everyone who's tried this patch can post a list of devices they've tested with to help ease Google's concerns about reliablity?
[Android Software/Hacking General [Developers Only]] d3vyarth:
But this patch will affect aptx and ldac in terms of business, so will google help? It would be hard for them to implement directly but they can provide support for implementation of this as an independent module being harmless.
[Android Software/Hacking General [Developers Only]] Skittles9823:
Affecting aptX and LDAC on the business side is in the interests of Google. They could choose to not pay Qualcomm or Sony to use the codec in the pixel line.
[Android Software/Hacking General [Developers Only]] Maverick Jester:
LDAC is implemented royalty-free in AOSP. It's a similar move to what Sony did with the original theme engine.
[Android Software/Hacking General [Developers Only]] Skittles9823:
TIL. I suppose that makes sense when it comes to marketing LDAC headphones on Sony's part.
[Android Software/Hacking General [Developers Only]] arunsai123:
How to get this working on AOSP based Q custom ROMS? My daily driver ROM(StagOS) doesn't have HD SBC option. Is there any guide/instruction to patch ROM libraries of android 10?
[Android Software/Hacking General [Developers Only]] d3vyarth:
Only option is to flash a ROM patched with this module, major ROMs like Lineage and RR have it. OP has mentioned a list having this feature, go check it and choose one.

Or you can try magisk module first, but it's not guaranteed to work on Q.
[Android Software/Hacking General [Developers Only]] Skittles9823:
Lineage hasn't merged in SBC xq in A10, and RR is dead.
[Android Software/Hacking General [Developers Only]] joedajoester:
I also have a pixel 3a and was thinking about getting galaxy buds or something similar and now I'm wondering if it's even worth it since the quality is significantly worse on non-samsung phones due to the lack of their proprietary codec. Is there any way to get SBC dual channel on a 3a today if lineage hasn't merged it? I'm not sure what to do but I'd really try anything to get it working.
[Android Software/Hacking General [Developers Only]] Skittles9823:
No Q ROMs have it merged in. If you're on Pie you should be able to find one though.

Personally the Bluetooth audio quality is fine enough if you have a decent pair of TWEs with at least aptX. I've been using a pair of the liberty 2 pros for a little under a year now and they've been great.
[Android Software/Hacking General [Developers Only]] zyhk:
I've heard that Google's devices are set DRC on all audio output while Samsung's are not.

Please check if 'speaker_drc_enabled' is true or false in /vender/etc/audio_policy_configuration.xml. (Don't use Pie GSIs, they may have a bug that cannot disable DRC on bluetooth audio output)
[Android Software/Hacking General [Developers Only]] joedajoester:
DRC is enabled on my 3a. What does this mean?
[Android Software/Hacking General [Developers Only]] zyhk:
See #283 in detail. In short, 'DRC enabled' means that your device is not for Hi-Fi audio listening and your have listened to distorted music till now on the device.
[Android Software/Hacking General [Developers Only]] joedajoester:
I'll try to disable it and see if there's any difference. When you say distortion, what do you mean? I'm really into audio and I don't notice any bit of distortion or clipping in my audio. I even have my media player gain set negative to avoid any sort of distortion.
[Android Software/Hacking General [Developers Only]] zyhk:
As you may know soon, the DRC (Dynamic Range Control or Compression) is used to force music under a limited loudness (-15dB or so) while losing audio quality (liveliness or clearness).
[Android Software/Hacking General [Developers Only]] AndUser254:
It said i need to have a root privilege if i want to do this by android but i dont want to root my devices.Is there any other ways to unlock this sbc xq? Via adb or anything?
[Android Software/Hacking General [Developers Only]] skanadian:
The AOSP and Lineage 17.1 commits for 10 make "Dual Channel" available in developer options, but the HD SBC toggle doesn't appear in bluetooth devices. Anyone know how to fix that, or have a commit I can target? [MENTION=685332]ValdikSS[/MENTION]

edit: doublepost, for "10" not PIE!
[Android Software/Hacking General [Developers Only]] Andyjack99:
Does it work in dual channel after forcing it ?
[Android Software/Hacking General [Developers Only]] skanadian:
It does but only while the device is connected.
[Android Software/Hacking General [Developers Only]] bl4dy_pt:
This is very interesting,

I've tried to change it to false, but it goes back to true after reboot.

Any thoughts?

PS : I'm on pixel 4 andoid 10
[Android Software/Hacking General [Developers Only]] abhifx:
Interesting! So basically just cherry picking android 9 commits works on android 10? I thought the bluetooth stack changed a lot?

Or am i getting it wrong, the commits pending to be merged in android 10 is kind of working?
[Android Software/Hacking General [Developers Only]] skanadian:
I don't know why I wrote "for pie" ... I was testing the commits against AOSP android 10. The commits pending for 10 are kind of working, selecting "dual channel" in developer options works, but the toggle doesn't show up in bluetooth devices.

These are the commits in the lineage 17.1 branch; https://review.lineageos.org/q/topic:"ten-bt-sbc-hd-dualchannel"
[Android Software/Hacking General [Developers Only]] zyhk:
I don't know the reason, but guess your vendor area has been protected against modifications. I think it could go well to replace original audio_policy_configuration.xml with modified one on TWRP recovery.

Don't forget to backup the original one for restoring it if it caused bootloop or like.

Edit:

See how to modify files under the vendor area. You need a magisk module to replace a string 'speaker_drc_enabled="true"' with 'speaker_drc_enabled="false"'.

Edit2:

I tried to make a magisk module to remove the DRC for Android 8, 9 and 10 in general even though the vendor area can be modified. Enjoy it if your "effective" audio_policy_configuration.xml is exactly "/vendor/etc/audio_policy_configuration.xml".

Edit3:

magisk module has been updated for "/sbin" less ROMs (Android 11).
[Android Software/Hacking General [Developers Only]] AoEKiller:
Narsil already turn off DRC in xml vendor file.
[Android Software/Hacking General [Developers Only]] zyhk:
Android 10 ROMs available now

Anyway, there have been SBC HD capable Android 10 ROMs around now. I tested the Bless GSI ROM (BlissOS v12.10 based GSI) and confirmed that SBC HD was enabled via dev options by a bluetooth snoop log.
[Android Software/Hacking General [Developers Only]] skanadian:
Yeah, it definitely works in dev options but toggling on every connect is a bit of a hassle. It would be nice to see a 10 commit that enables the toggle in settings > devices.
[Android Software/Hacking General [Developers Only]] zyhk:
There are two tunables in dev options, i.e. "Bluetooth Audio Codec (preferred)" and "SBC HD audio". It seems that we can set SBC HD as a default if we use them. My AAC&SBC capable earphones actually connect to my phone with SBC HD automatically.
[Android Software/Hacking General [Developers Only]] bl4dy_pt:
Thanks buddy, will try now and report back :good:

Update: it worked :svetius:

I can definitely hear a difference.

Do you know the rate of compression with DRC on?
[Android Software/Hacking General [Developers Only]] VincentJoshuaET:
Which is more battery efficient, SBC HD or aptX?
[Android Software/Hacking General [Developers Only]] zyhk:
I don't know the rate, but can hear the difference down to -15dB input gain.
[Android Software/Hacking General [Developers Only]] als123:
When enabled dual channel option, the airdot tws is muted, unlike the stereo option. Any solution?
[Android Software/Hacking General [Developers Only]] zyhk:
Don't you use an Android 10 ROM? I think most Android 10 ROM's cannot use dual channel by a bug. At least Oreo&Pie ROM's and Bless GSI are OK.
[Android Software/Hacking General [Developers Only]] als123:
Oh i see., indeed i am in Android 10. Any workaround? Tx bro
[Android Software/Hacking General [Developers Only]] pranavrocksharma:
Bro op can you please port this on oxygen os running Android 10 please
[Android Software/Hacking General [Developers Only]] cloneman1:
Is it possible to check the bitrate that Bluetooth is currently connected at?

I don't have SBC XQ but I want to make sure my car is at least using 328kbps.
[Android Software/Hacking General [Developers Only]] abhifx:
it looks the patches are in for Android 11, Lineage 18.1.

finger crossed for merger
[Android Software/Hacking General [Developers Only]] dandreye:
Hi All,

Could anyone (besides ValdikSS himself) familiar well enough with Bluedroid stack implementation in Android 8 AOSP please refer me to a particular function in a2dp_sbc.cc , a2dp_sbc_encoder.cc or perhaps in some other neighbour cc file called whenever audio playback is started? After patching /system/lib/hw/bluetooth.default.so as per ValdikSS's instructions I now have SBC DC selected by Samsung SM-A320FL running stock Android 8 ROM every time upon connecting to A2DP sink, however as soon as I start the very first audio playback it falls back to JS: first it tries changing it on the fly with Reconfigure on the channel opened earlier, the sink rejects that command as unsupported and it then closes down the channel and reopens it with JS instead. Knowing the answer will let me avoid studying Bluedroid source code myself :)

Many thanks in anticipation!

Update

: just circumvented it by means of binary patching A2DP_ParseSinkCaps in a2dp_sbc.cc stripping off the support of any other SBC channel modes but DC in the sink caps advertised towards the phone. That'll do for my own needs although getting the answer one day would help hack it less brutally than that.

Spoiler content hidden.
[Android Software/Hacking General [Developers Only]] dewettie:
Hi

Can anyone add Android 10 support for a Magisk module for SBC HD?

GitHub - gjf/gjf_bt: Bluetooth stack bitrate changer + aptX&aptX-HD Enabler

Bluetooth stack bitrate changer + aptX&aptX-HD Enabler - gjf/gjf_bt

github.com
[Android Software/Hacking General [Developers Only]] abhifx:
quoting myself, SBC HD has been merged in Lineage gerrit for A11.
[Android Software/Hacking General [Developers Only]] dandreye:
Could anyone who has SBC HD/XQ with any Anrdoid 8 based ROM please check if there's ever more than 2 frames per packet in audio transmission? Looks like mine always puts exactly 2 with DC-16-8-53, hence frame size 224 bytes, while in JS mode it puts more frames (smaller ones though). Raising MTU from default 663 to 1005 (1021 incl the headers) in function calculate_max_frames_per_packet doesn't help and forcing that MTU breaks transmission: big packets alternating with small ones and displayed as malformed in Wireshark etc.

Update

: Apparently 3 frames fit into a packet with max bitpool reduced down to 51, so perhaps I just didn't find all the places with MTU=663 to raise.
[Android Software/Hacking General [Developers Only]] klaberte:
I am not a developer, nor very familiar with Lineage, but will gladly move my Pixel 5 to Lineage 18.1 if it enables SBC HD (dual channel mode). Not doubting you, but can you point to how you know/suspect this? Have you tried it on Lineage 18.1? What phone model? etc.
[Android Software/Hacking General [Developers Only]] abhifx:
Well, I am just informing that the commits have been merged. the same is working or not has to be tested.

I am using Poco F1 with arrow os and although they also advertise as SBC HD patches merged, the HD option in Bluetooth still doesn't appear.

you might want to check at pixel 5 forum if its actually working or not.

here are commits

https://review.lineageos.org/q/status:merged+sbc
[Android Software/Hacking General [Developers Only]] zyhk:
SBC HD is working on unofficial Arrow OS 11.0 for Mi PAD4. I confirmed this by a Bluetooth HCI snoop log. There is no HD option, but you may select "Dual channel" in dev options.
[Android Software/Hacking General [Developers Only]] klaberte:
Thanks so much. I am not a coder, so I apologize for these basic questions. Does being merged into the mean LOS mean that builds for all devices, build after this date, should be available for all devices? In addition to this repo, is there a second code review that needs to happen with each device?
[Android Software/Hacking General [Developers Only]] abhifx:
Well that's the thing, i am not getting the dual channel option
[Android Software/Hacking General [Developers Only]] abhifx:
Well this is not device specific so yes this should work in every device post merger
[Android Software/Hacking General [Developers Only]] dandreye:
Hi All,

Has anyone tried SBC-HD JS (effectively JS with 4 subbands) as per Bluetooth LC-SBC and SBC-HBR Explained by Ken Laberteaux? The first impression seems to be somewhat more bass vs ValdikSS's SBC-HD XQ/DC in my rather bassy recording although I'm badly lacking decent quality audio equipment at the moment to assess it comprehensively. With that mod my 44.1kHz JS634Kbps-16-4-53 audio stream from Samsung SM-A310F to Rod Rain Audio CSR8675 DAC carries 7x 116-byte frames per 827-byte packet (all incl) and Wireshark RTP analysis shows BW reaching ~670Kbps.
[Android Software/Hacking General [Developers Only]] klaberte:
Have you seen the SBC calculator at valdikSS' (the starter of this thread) site? This will allow you to see how parameter combinations impact frame size, MTU, etc.

Bluetooth A2DP SBC Bitrate Calculator

Bluetooth A2DP SBC audio codec bitrate calculator

btcodecs.valdikss.org.ru

Also, JS should create smaller frames, as the individual channels of stereo audio are often highly correlated. JS allows us to encode these two channels more efficiently.
[Android Software/Hacking General [Developers Only]] klaberte:
See if this helps:

How do I determine which A2DP codecs my phone supports/is currently using?

Bluetooth's Audio Profile A2DP supports multiple codecs. All devices have to support SBC (subband codec), then they can support additional "optional codecs" like MP3 and AAC, or "non-A2DP" codecs ...

android.stackexchange.com
[Android Software/Hacking General [Developers Only]] klaberte:
I'm not certain, but the most battery efficient should be the one that requires the least computations per second of audio. SBC (all variants) was the original A2DP codec, and was definitely designed to be computationally light. It was defined back in the early 2000's for use on devices much less powerful that we have today. In short, I would expect any SBC codec to be the most battery friendly, but have not tested this.
[Android Software/Hacking General [Developers Only]] blackhawk:
Probably SBC but we're not talking about that much power drain to begin with.

The difference I see between SSC and SBC isn't even noticeable.
[Android Software/Hacking General [Developers Only]] klaberte:
Sorry for so many posts at the same time...

For both valdikss' SBC-HQ and my SBC-HBR are simply SBC, but using combinations of parameters that are 'not frequently used, but should be compatible'. The image attached gives the approximate bitrate of the audio payload, removing headers and other overhead. Both are trying to basically double the audio bit rate.

Neither SBC-HQ or SBC-HBR should intuitively create "more bass", but should give more accurate (less distortion) audio in all bands. But in Loudness mode (the default), both will tend to shift bits to the lowest eighth (HQ) or quarter (HBR) of the audio spectrum.

Stated more directly, neither SBC-HQ or -HBR should create more bass, but should create higher resolution.(more accuracy) in the lower frequency bands.
[Android Software/Hacking General [Developers Only]] dandreye:
Thank you for that article on LC-SBC and SBC-HBR :) I wish I familiarized with it earlier as I found those subbands easier to binary patch than ch mode. I've been using ValdikSS's Bluetooth A2DP Codec Dissection for a long time and here's the output from it for my SBC-HBR audio stream described above:

Connection:
localhost (Galaxy A3 (2016)) → 40:ed:98:19:8d:2a (ROD RAIN 5.0PRO)

Supported codecs:
Audio non-A2DP (LDAC - 44100 48000 88200 96000, Mono DualChannel Stereo)
Audio non-A2DP
Audio non-A2DP (aptX Low Latency - 44100 48000, Stereo)
Audio non-A2DP (aptX HD - 44100 48000, Stereo)
Audio non-A2DP (aptX - 44100 48000, Stereo)
Audio MPEG-2,4 AAC
Audio SBC (16000 32000 44100 48000 | Mono DualChannel Stereo JointStereo | block: 4 8 12 16 | subbands: 4 8 | allocation: SNR Loudness | bitpool: 2..53)

Used for audio:
Audio SBC (44100 | JointStereo | block: 16 | subbands: 4 | allocation: Loudness | bitpool: 2..53)

Latest SBC Bitpool value: 53

Wrt the bass, in his articles ValdikSS says SBC allocates the bits "on demand" starting from low frequencies to high, and I certainly recall getting a mad bass never heard before with any other codec when testing his XQ/DC with one of my source+sink+music combinations. I couldn't recall which particular music tracks they were though and used random ones when testing your SBC-HBR recently, and it seemed like there's a tad more bass although it's very subjective. I must admit there was a short period of audio clipping in pretty ideal conditions at some point (~2m apart in a room, no obstacles), which went away upon turning off WiFi and didn't reoccur much later when I re-enabled WiFi eventually. I'll test it further when I have time.

Wrt power consumption I even thought SBC goes over LE as it was hardly using the battery - until I learned it's only over classic, so it's certainly not a concern with SBC.
[Android Software/Hacking General [Developers Only]] klaberte:
Of course, you would be a hero if you could provide step-by-step instructions on how to enable SBC-HBR (or SBC-HQ) on arbitrary ROMs, or even those that are heavily based on AOSP!
[Android Software/Hacking General [Developers Only]] klaberte:
This observation seems consistent with what I wrote in the white paper in the section "Increasing the bitrate", which starts on the last line of p9.

I certainly would be interested in any other testing you should do.

One way to reduce the likelihood of interference would be to reduce the size/length of the A2DP packets. While there are various ways to do this, I think the easiest would be to simply reduce the size of the max bitpool.