OSDN Git Service

Always restrict the AVDTP MTU for SBC codec to MAX_2MBPS_AVDTP_MTU(663)
authorPavlin Radoslavov <pavlin@google.com>
Tue, 28 Feb 2017 23:30:21 +0000 (15:30 -0800)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 1 Mar 2017 00:14:39 +0000 (16:14 -0800)
Some devices claim they can handle large MTU and large SBC bitpool.
However, they are struggling and eventually over time they
start delaying the "Rcvd Number of Completed Packets" reports.
Now we always limit the payload MTU to MAX_2MBPS_AVDTP_MTU(663) -
with the overhead of (4 bytes L2CAP Header + 12 bytes AVDTP Header)
such packet can fit within 2-DH5 payload size of 679 bytes.

Bug: 34127145
Test: A2DP SBC streaming to headsets and carkit
Change-Id: I2f32becba703d77d36be46158f68b8a9ef3f299a

stack/a2dp/a2dp_sbc_encoder.cc

index 0beb153..5518461 100644 (file)
@@ -746,21 +746,14 @@ static uint8_t calculate_max_frames_per_packet(void) {
 
   LOG_VERBOSE(LOG_TAG, "%s: original AVDTP MTU size: %d", __func__,
               a2dp_sbc_encoder_cb.TxAaMtuSize);
-  if (a2dp_sbc_encoder_cb.is_peer_edr &&
-      !a2dp_sbc_encoder_cb.peer_supports_3mbps) {
-    // This condition would be satisfied only if the remote device is
-    // EDR and supports only 2 Mbps, but the effective AVDTP MTU size
-    // exceeds the 2DH5 packet size.
-    LOG_VERBOSE(LOG_TAG,
-                "%s: The remote device is EDR but does not support 3 Mbps",
-                __func__);
 
-    if (effective_mtu_size > MAX_2MBPS_AVDTP_MTU) {
-      LOG_WARN(LOG_TAG, "%s: Restricting AVDTP MTU size to %d", __func__,
-               MAX_2MBPS_AVDTP_MTU);
-      effective_mtu_size = MAX_2MBPS_AVDTP_MTU;
-      a2dp_sbc_encoder_cb.TxAaMtuSize = effective_mtu_size;
-    }
+  // Restrict the MTU - even though some Sink devices are advertising large
+  // MTU, they are not able to handle the packets and are stuttering.
+  if (effective_mtu_size > MAX_2MBPS_AVDTP_MTU) {
+    LOG_WARN(LOG_TAG, "%s: Restricting AVDTP MTU size to %d", __func__,
+             MAX_2MBPS_AVDTP_MTU);
+    effective_mtu_size = MAX_2MBPS_AVDTP_MTU;
+    a2dp_sbc_encoder_cb.TxAaMtuSize = effective_mtu_size;
   }
 
   if (!p_encoder_params->s16NumOfSubBands) {