Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96f69ca1 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

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
(cherry picked from commit 37a5d291)
parent 08e3ffc0
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -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);