OSDN Git Service

Ignore AAC bitrate from the A2DP Sink device if below a threshold
authorPavlin Radoslavov <pavlin@google.com>
Fri, 17 Feb 2017 17:53:52 +0000 (09:53 -0800)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 1 Mar 2017 00:10:06 +0000 (16:10 -0800)
Some Sink devices might advertise AAC zero bitrate or a very small
value (e.g., 24576). Ignore values that are below a threshold
(currently set to 64000), because those seem invalid.
For such devices, the actual streaming bitrate will be computed
based on the MTU.

Test: Code compilation
Change-Id: Ibe3de6e53681a618f388b41a01f366ad462b7a1d

stack/a2dp/a2dp_aac.cc

index d06ac79..136f0b6 100644 (file)
@@ -960,16 +960,21 @@ bool A2dpCodecConfigAac::setCodecConfig(const uint8_t* p_peer_codec_info,
   result_config_cie.variableBitRateSupport =
       a2dp_aac_caps.variableBitRateSupport;
 
-  // Set the bit rate to the smaller of the local and peer bit rate
-  // However, make sure the bit rate doesn't go beyond a certain threshold
-  if (sink_info_cie.bitRate == 0) {
-    // NOTE: Some devices report bitRate of zero - in that case use our bitRate
+  // Set the bit rate as follows:
+  // 1. If the Sink device reports a bogus bit rate
+  //    (bitRate < A2DP_AAC_MIN_BITRATE), then use the bit rate from our
+  //    configuration. Examples of observed bogus bit rates are zero
+  //    and 24576.
+  // 2. If the Sink device reports valid bit rate
+  //    (bitRate >= A2DP_AAC_MIN_BITRATE), then use the smaller
+  //    of the Sink device's bit rate and the bit rate from our configuration.
+  // In either case, the actual streaming bit rate will also consider the MTU.
+  if (sink_info_cie.bitRate < A2DP_AAC_MIN_BITRATE) {
+    // Bogus bit rate
     result_config_cie.bitRate = a2dp_aac_caps.bitRate;
   } else {
     result_config_cie.bitRate =
         std::min(a2dp_aac_caps.bitRate, sink_info_cie.bitRate);
-    result_config_cie.bitRate = std::max(
-        result_config_cie.bitRate, static_cast<uint32_t>(A2DP_AAC_MIN_BITRATE));
   }
 
   //