DivestOS/Patches/LineageOS-17.1/android_system_bt/272648.patch
Tad b5bc269743
SBC dualchannel picks
Signed-off-by: Tad <tad@spotco.us>
2022-12-18 21:47:22 -05:00

58 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ValdikSS <iam@valdikss.org.ru>
Date: Sun, 9 Sep 2018 01:50:42 +0300
Subject: [PATCH] Increase maximum Bluetooth SBC codec bitrate for SBC HD
This commit increases maximum possible bitrate to 452 kbit/s for 44.1 kHz,
492 kbit/s for 48 kHz, which is optimal for both
EDR 2 mbit/s (4 audio frames, 11.7 ms, 6 wasted bytes) and
EDR 3 mbit/s (6 audio frames, 17.5 ms, 20 wasted bytes).
It does not increase bitpool value and won't introduce higher bitrates for
modes other than SBC Dual Channel.
Change-Id: I43f0b48f8b99bfb296c6b5a0b7fdb4d0592f5f82
---
stack/a2dp/a2dp_sbc_encoder.cc | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/stack/a2dp/a2dp_sbc_encoder.cc b/stack/a2dp/a2dp_sbc_encoder.cc
index aac7e6d18..16d28e808 100644
--- a/stack/a2dp/a2dp_sbc_encoder.cc
+++ b/stack/a2dp/a2dp_sbc_encoder.cc
@@ -39,15 +39,19 @@
// A2DP SBC encoder interval in milliseconds.
#define A2DP_SBC_ENCODER_INTERVAL_MS 20
-/* High quality quality setting @ 44.1 khz */
-#define A2DP_SBC_DEFAULT_BITRATE 328
+/*
+ * Higher quality setting. 492 kbps @ 48 khz, 452 kbps @ 44.1 khz.
+ * Up to 4 frames for 2DH5, 6 frames for 3DH5.
+ */
+#define A2DP_SBC_DEFAULT_BITRATE 454
+#define A2DP_SBC_48KHZ_BITRATE 494
#define A2DP_SBC_NON_EDR_MAX_RATE 229
#define A2DP_SBC_MAX_PCM_ITER_NUM_PER_TICK 3
-#define A2DP_SBC_MAX_HQ_FRAME_SIZE_44_1 119
-#define A2DP_SBC_MAX_HQ_FRAME_SIZE_48 115
+#define A2DP_SBC_MAX_HQ_FRAME_SIZE_44_1 165
+#define A2DP_SBC_MAX_HQ_FRAME_SIZE_48 165
/* Define the bitrate step when trying to match bitpool value */
#define A2DP_SBC_BITRATE_STEP 5
@@ -832,6 +836,10 @@ static uint8_t calculate_max_frames_per_packet(void) {
static uint16_t a2dp_sbc_source_rate() {
uint16_t rate = A2DP_SBC_DEFAULT_BITRATE;
+ if (a2dp_sbc_encoder_cb.sbc_encoder_params.s16SamplingFreq == SBC_sf48000) {
+ rate = A2DP_SBC_48KHZ_BITRATE;
+ }
+
/* restrict bitrate if a2dp link is non-edr */
if (!a2dp_sbc_encoder_cb.is_peer_edr) {
rate = A2DP_SBC_NON_EDR_MAX_RATE;