Experimental Bluetooth audio quailty improvement patches, credit @ValdikSS

This commit is contained in:
Tad 2018-08-23 22:31:43 -04:00
parent 1983d9a8f7
commit 642f978509
4 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,57 @@
From 93e456e4a21bdb0a03050001b02f9e2dba653306 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 23 Aug 2018 22:23:28 -0400
Subject: [PATCH] Improve Bluetooth audio quality, credit @ValdikSS
Change-Id: Ia6282d5e76ea7df0d8e0c56559f71c333d6b04eb
See: https://forum.xda-developers.com/android/software-hacking/improve-bluetooth-audio-quality-t3832615
---
btif/co/bta_av_co.c | 8 ++++----
btif/src/btif_media_task.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c
index 39a8ebfa..1d86469d 100644
--- a/btif/co/bta_av_co.c
+++ b/btif/co/bta_av_co.c
@@ -130,7 +130,7 @@ const tA2D_SBC_CIE bta_av_co_sbc_sink_caps =
const tA2D_SBC_CIE btif_av_sbc_default_config =
{
BTIF_AV_SBC_DEFAULT_SAMP_FREQ, /* samp_freq */
- A2D_SBC_IE_CH_MD_JOINT, /* ch_mode */
+ A2D_SBC_IE_CH_MD_DUAL, /* ch_mode */
A2D_SBC_IE_BLOCKS_16, /* block_len */
A2D_SBC_IE_SUBBAND_8, /* num_subbands */
A2D_SBC_IE_ALLOC_MD_L, /* alloc_mthd */
@@ -566,12 +566,12 @@ void bta_av_build_src_cfg (UINT8 *p_pref_cfg, UINT8 *p_src_cap)
else if (src_cap.samp_freq & A2D_SBC_IE_SAMP_FREQ_44)
pref_cap.samp_freq = A2D_SBC_IE_SAMP_FREQ_44;
- if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_JOINT)
+ if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_DUAL)
+ pref_cap.ch_mode = A2D_SBC_IE_CH_MD_DUAL;
+ else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_JOINT)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_JOINT;
else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_STEREO)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_STEREO;
- else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_DUAL)
- pref_cap.ch_mode = A2D_SBC_IE_CH_MD_DUAL;
else if (src_cap.ch_mode & A2D_SBC_IE_CH_MD_MONO)
pref_cap.ch_mode = A2D_SBC_IE_CH_MD_MONO;
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 977d2668..a8ad735c 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -214,7 +214,7 @@ enum {
#define BTIF_A2DP_NON_EDR_MAX_RATE 237
#endif
#else
-#define BTIF_A2DP_DEFAULT_BITRATE 328
+#define BTIF_A2DP_DEFAULT_BITRATE 512
#ifndef BTIF_A2DP_NON_EDR_MAX_RATE
#define BTIF_A2DP_NON_EDR_MAX_RATE 229
--
2.18.0

View File

@ -0,0 +1,74 @@
From 133e43eb4f5339e584dc2dcc3f02a34711c93571 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 23 Aug 2018 22:16:42 -0400
Subject: [PATCH] Improve Bluetooth audio quality, credit @ValdikSS
Change-Id: I98f5b84982aaf446e5adfb622993ee11f4592f64
See: https://forum.xda-developers.com/android/software-hacking/improve-bluetooth-audio-quality-t3832615
---
stack/a2dp/a2dp_sbc.cc | 14 +++++++-------
stack/a2dp/a2dp_sbc_encoder.cc | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/stack/a2dp/a2dp_sbc.cc b/stack/a2dp/a2dp_sbc.cc
index cfdaad4c..1416d4c3 100644
--- a/stack/a2dp/a2dp_sbc.cc
+++ b/stack/a2dp/a2dp_sbc.cc
@@ -55,7 +55,7 @@ typedef struct {
/* SBC SRC codec capabilities */
static const tA2DP_SBC_CIE a2dp_sbc_caps = {
A2DP_SBC_IE_SAMP_FREQ_44, /* samp_freq */
- (A2DP_SBC_IE_CH_MD_MONO | A2DP_SBC_IE_CH_MD_JOINT), /* ch_mode */
+ (A2DP_SBC_IE_CH_MD_MONO | A2DP_SBC_IE_CH_MD_JOINT | A2DP_SBC_IE_CH_MD_DUAL), /* ch_mode */
(A2DP_SBC_IE_BLOCKS_16 | A2DP_SBC_IE_BLOCKS_12 | A2DP_SBC_IE_BLOCKS_8 |
A2DP_SBC_IE_BLOCKS_4), /* block_len */
A2DP_SBC_IE_SUBBAND_8, /* num_subbands */
@@ -82,7 +82,7 @@ static const tA2DP_SBC_CIE a2dp_sbc_sink_caps = {
/* Default SBC codec configuration */
const tA2DP_SBC_CIE a2dp_sbc_default_config = {
A2DP_SBC_IE_SAMP_FREQ_44, /* samp_freq */
- A2DP_SBC_IE_CH_MD_JOINT, /* ch_mode */
+ A2DP_SBC_IE_CH_MD_DUAL, /* ch_mode */
A2DP_SBC_IE_BLOCKS_16, /* block_len */
A2DP_SBC_IE_SUBBAND_8, /* num_subbands */
A2DP_SBC_IE_ALLOC_MD_L, /* alloc_method */
@@ -1154,6 +1154,11 @@ static bool select_audio_bits_per_sample(
//
static bool select_best_channel_mode(uint8_t ch_mode, tA2DP_SBC_CIE* p_result,
btav_a2dp_codec_config_t* p_codec_config) {
+ if (ch_mode & A2DP_SBC_IE_CH_MD_DUAL) {
+ p_result->ch_mode = A2DP_SBC_IE_CH_MD_DUAL;
+ p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
+ return true;
+ }
if (ch_mode & A2DP_SBC_IE_CH_MD_JOINT) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_JOINT;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
@@ -1164,11 +1169,6 @@ static bool select_best_channel_mode(uint8_t ch_mode, tA2DP_SBC_CIE* p_result,
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
return true;
}
- if (ch_mode & A2DP_SBC_IE_CH_MD_DUAL) {
- p_result->ch_mode = A2DP_SBC_IE_CH_MD_DUAL;
- p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
- return true;
- }
if (ch_mode & A2DP_SBC_IE_CH_MD_MONO) {
p_result->ch_mode = A2DP_SBC_IE_CH_MD_MONO;
p_codec_config->channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_MONO;
diff --git a/stack/a2dp/a2dp_sbc_encoder.cc b/stack/a2dp/a2dp_sbc_encoder.cc
index e4c20499..8b3731d1 100644
--- a/stack/a2dp/a2dp_sbc_encoder.cc
+++ b/stack/a2dp/a2dp_sbc_encoder.cc
@@ -39,7 +39,7 @@
#define A2DP_SBC_ENCODER_INTERVAL_MS 20
/* High quality quality setting @ 44.1 khz */
-#define A2DP_SBC_DEFAULT_BITRATE 328
+#define A2DP_SBC_DEFAULT_BITRATE 512
#define A2DP_SBC_NON_EDR_MAX_RATE 229
--
2.18.0

View File

@ -146,6 +146,9 @@ sed -i 's/WallpaperUtils.EXTRA_WALLPAPER_OFFSET, 0);/WallpaperUtils.EXTRA_WALLPA
enterAndClear "packages/inputmethods/LatinIME";
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_inputmethods_LatinIME/0001-Voice.patch"; #Remove voice input key
enterAndClear "system/bt";
patch -p1 < "$DOS_PATCHES/android_system_bt/Improve_Quality.patch"; #Improve Bluetooth audio quality, credit @ValdikSS
enterAndClear "system/core";
if [ "$DOS_HOSTS_BLOCKING" = true ]; then cat "$DOS_HOSTS_FILE" >> rootdir/etc/hosts; fi; #Merge in our HOSTS file
git revert 0217dddeb5c16903c13ff6c75213619b79ea622b d7aa1231b6a0631f506c0c23816f2cd81645b15f; #Always update recovery XXX: This doesn't seem to work

View File

@ -147,6 +147,9 @@ sed -i 's/WallpaperUtils.EXTRA_WALLPAPER_OFFSET, 0);/WallpaperUtils.EXTRA_WALLPA
enterAndClear "packages/inputmethods/LatinIME";
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_inputmethods_LatinIME/0001-Voice.patch"; #Remove voice input key
enterAndClear "system/bt";
patch -p1 < "$DOS_PATCHES/android_system_bt/Improve_Quality.patch"; #Improve Bluetooth audio quality, credit @ValdikSS
enterAndClear "system/core";
if [ "$DOS_HOSTS_BLOCKING" = true ]; then cat "$DOS_HOSTS_FILE" >> rootdir/etc/hosts; fi; #Merge in our HOSTS file
git revert a6a4ce8e9a6d63014047a447c6bb3ac1fa90b3f4; #Always update recovery