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

Commit 73d42aff authored by Can Chen's avatar Can Chen Committed by Guillaume Bailey
Browse files

BT NE when codec dynamic switch

[Root Cause]
1. Codec dynamic switch will make AVRCP close
2. AVRCP close will trigger set kEmpty addr to active peer
3. step 2 will cause codec config being formatted into 0

[Solution]
save new codec when decoder

Bug: 270271435
Test: atest net_test_bta pass

Change-Id: Ic4acaf09cca4193cb3d243535a0fc3f5c62701f6
parent 64a7f09f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -389,6 +389,13 @@ class BtaAvCo {
   */
  bool SetActivePeer(const RawAddress& peer_address);

  /**
   * Save the reconfig codec
   *
   * @param new_codec_config the new codec config
   */
   void SaveCodec(const uint8_t* new_codec_config);

  /**
   * Get the encoder parameters for a peer.
   *
@@ -1465,6 +1472,10 @@ bool BtaAvCo::SetActivePeer(const RawAddress& peer_address) {
  return true;
}

void BtaAvCo::SaveCodec(const uint8_t* new_codec_config) {
  memcpy(codec_config_, new_codec_config, sizeof(codec_config_));
}

void BtaAvCo::GetPeerEncoderParameters(
    const RawAddress& peer_address,
    tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params) {
@@ -2241,6 +2252,10 @@ bool bta_av_co_set_active_peer(const RawAddress& peer_address) {
  return bta_av_co_cb.SetActivePeer(peer_address);
}

void bta_av_co_save_codec(const uint8_t* new_codec_config) {
  return bta_av_co_cb.SaveCodec(new_codec_config);
}

void bta_av_co_get_peer_params(const RawAddress& peer_address,
                               tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params) {
  bta_av_co_cb.GetPeerEncoderParameters(peer_address, p_peer_params);
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
// Returns true on success, otherwise false.
bool bta_av_co_set_active_peer(const RawAddress& peer_addr);

void bta_av_co_save_codec(const uint8_t* new_codec_config);

// Gets the A2DP peer parameters that are used to initialize the encoder.
// The peer address is |peer_addr|.
// The parameters are stored in |p_peer_params|.
+3 −0
Original line number Diff line number Diff line
@@ -631,8 +631,11 @@ static void btif_a2dp_sink_decoder_update_event(
  btif_a2dp_sink_cb.rx_flush = false;
  APPL_TRACE_DEBUG("%s: reset to Sink role", __func__);

  bta_av_co_save_codec(p_buf->codec_info);

  btif_a2dp_sink_cb.decoder_interface =
      A2DP_GetDecoderInterface(p_buf->codec_info);

  if (btif_a2dp_sink_cb.decoder_interface == nullptr) {
    LOG_ERROR("%s: cannot stream audio: no source decoder interface", __func__);
    return;