[PATCH v7 06/13] bluetooth: Clean up SBC bitpool calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove dead code and replace numeric bitpool values by macro definitions.

Maximal bitpool value in fill_capabilities() was reduced from 64 to 53
(SBC_BITPOOL_HQ_JOINT_STEREO_44100) because default_bitpool() already set
maximal value to 53.

This patch does not change SBC behavior as maximal bitpool was already
limited to 53. So it is just clean up.
---
 src/modules/bluetooth/a2dp-codec-sbc.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/modules/bluetooth/a2dp-codec-sbc.c b/src/modules/bluetooth/a2dp-codec-sbc.c
index 170dfc39d..034d57a69 100644
--- a/src/modules/bluetooth/a2dp-codec-sbc.c
+++ b/src/modules/bluetooth/a2dp-codec-sbc.c
@@ -104,7 +104,7 @@ static uint8_t fill_capabilities(uint8_t capabilities_buffer[254]) {
     capabilities->subbands = SBC_SUBBANDS_4 | SBC_SUBBANDS_8;
     capabilities->block_length = SBC_BLOCK_LENGTH_4 | SBC_BLOCK_LENGTH_8 | SBC_BLOCK_LENGTH_12 | SBC_BLOCK_LENGTH_16;
     capabilities->min_bitpool = SBC_MIN_BITPOOL;
-    capabilities->max_bitpool = 64;
+    capabilities->max_bitpool = SBC_BITPOOL_HQ_JOINT_STEREO_44100;
 
     return sizeof(*capabilities);
 }
@@ -158,41 +158,38 @@ static uint8_t default_bitpool(uint8_t freq, uint8_t mode) {
     switch (freq) {
         case SBC_SAMPLING_FREQ_16000:
         case SBC_SAMPLING_FREQ_32000:
-            return 53;
+            switch (mode) {
+                case SBC_CHANNEL_MODE_MONO:
+                case SBC_CHANNEL_MODE_DUAL_CHANNEL:
+                case SBC_CHANNEL_MODE_STEREO:
+                case SBC_CHANNEL_MODE_JOINT_STEREO:
+                    return SBC_BITPOOL_HQ_JOINT_STEREO_44100;
+            }
 
         case SBC_SAMPLING_FREQ_44100:
-
             switch (mode) {
                 case SBC_CHANNEL_MODE_MONO:
                 case SBC_CHANNEL_MODE_DUAL_CHANNEL:
-                    return 31;
+                    return SBC_BITPOOL_HQ_MONO_44100;
 
                 case SBC_CHANNEL_MODE_STEREO:
                 case SBC_CHANNEL_MODE_JOINT_STEREO:
-                    return 53;
+                    return SBC_BITPOOL_HQ_JOINT_STEREO_44100;
             }
 
-            pa_log_warn("Invalid channel mode %u", mode);
-            return 53;
-
         case SBC_SAMPLING_FREQ_48000:
-
             switch (mode) {
                 case SBC_CHANNEL_MODE_MONO:
                 case SBC_CHANNEL_MODE_DUAL_CHANNEL:
-                    return 29;
+                    return SBC_BITPOOL_HQ_MONO_48000;
 
                 case SBC_CHANNEL_MODE_STEREO:
                 case SBC_CHANNEL_MODE_JOINT_STEREO:
-                    return 51;
+                    return SBC_BITPOOL_HQ_JOINT_STEREO_48000;
             }
-
-            pa_log_warn("Invalid channel mode %u", mode);
-            return 51;
     }
 
-    pa_log_warn("Invalid sampling freq %u", freq);
-    return 53;
+    pa_assert_not_reached();
 }
 
 static uint8_t fill_preferred_configuration(const pa_sample_spec *default_sample_spec, const uint8_t *capabilities_buffer, uint8_t capabilities_size, uint8_t config_buffer[254]) {
-- 
2.11.0

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux