From d62e522131e8646830f846fdcb292870d7fb9d7b Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Fri, 12 May 2017 03:02:08 -0700 Subject: [PATCH] Don't ignore the A2DP Sink preferred SBC codec config 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 --- stack/a2dp/a2dp_sbc.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/stack/a2dp/a2dp_sbc.cc b/stack/a2dp/a2dp_sbc.cc index 5e3b6afaa..3d7afedad 100644 --- a/stack/a2dp/a2dp_sbc.cc +++ b/stack/a2dp/a2dp_sbc.cc @@ -1250,6 +1250,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 @@ -1572,13 +1583,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); -- 2.11.0