OSDN Git Service

Don't ignore the A2DP Sink preferred SBC codec config
authorPavlin Radoslavov <pavlin@google.com>
Fri, 12 May 2017 10:02:08 +0000 (03:02 -0700)
committerPavlin Radoslavov <pavlin@google.com>
Sun, 14 May 2017 02:42:42 +0000 (19:42 -0700)
If the A2DP Sink device sends "Set Configuration" with its preferred
SBC configuration, try using that configuration when selecting
the codec parameters instead of the A2DP Sink SBC capability.

Test: A2DP streaming, PTS AVDTP Tests: TC_ACP_SRC_SIG_SMG_BV_18_C,
      TC_ACP_SRC_SIG_SMG_BV_20_C, TC_ACP_SRC_SIG_SMG_BV_22_C
      PTS A2DP Tests: A2DP/SRC/SET/BV-04-I, A2DP/SRC/SET/BV-06-I
Bug: 37723311
Bug: 35664023
Change-Id: I48e2aa664b899c1cda5df4d1f86f9cfa3a9a67f6
(cherry picked from commit d62e522131e8646830f846fdcb292870d7fb9d7b)

stack/a2dp/a2dp_sbc.cc

index 091b2f7..f3918dd 100644 (file)
@@ -1263,6 +1263,17 @@ bool A2dpCodecConfigSbc::setCodecConfig(const uint8_t* p_peer_codec_info,
               __func__, status);
     goto fail;
   }
+  // Try using the prefered peer codec config (if valid), instead of the peer
+  // capability.
+  if (is_capability && A2DP_IsPeerSinkCodecValidSbc(ota_codec_peer_config_)) {
+    status = A2DP_ParseInfoSbc(&sink_info_cie, ota_codec_peer_config_, false);
+    if (status != A2DP_SUCCESS) {
+      // Use the peer codec capability
+      status =
+          A2DP_ParseInfoSbc(&sink_info_cie, p_peer_codec_info, is_capability);
+      CHECK(status == A2DP_SUCCESS);
+    }
+  }
 
   //
   // Build the preferred configuration
@@ -1585,13 +1596,12 @@ bool A2dpCodecConfigSbc::setCodecConfig(const uint8_t* p_peer_codec_info,
   // Create a local copy of the peer codec capability/config, and the
   // result codec config.
   if (is_capability) {
-    status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &sink_info_cie,
-                               ota_codec_peer_capability_);
+    memcpy(ota_codec_peer_capability_, p_peer_codec_info,
+           sizeof(ota_codec_peer_capability_));
   } else {
-    status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &sink_info_cie,
-                               ota_codec_peer_config_);
+    memcpy(ota_codec_peer_config_, p_peer_codec_info,
+           sizeof(ota_codec_peer_config_));
   }
-  CHECK(status == A2DP_SUCCESS);
   status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie,
                              ota_codec_config_);
   CHECK(status == A2DP_SUCCESS);