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

Commit 8cb13d02 authored by Sandeep Samdaria's avatar Sandeep Samdaria
Browse files

Codec information missing results in crash.

Problem: Due to race condition, the codec information can be
resetted in the bt_av_co instance. This results in decoder
interface to be initialized to null. When media is streamed,
the null interface results in stack to crash.

Solution: Codec information is retrieved from the decoder update
event instead of the "global" cache. A valid codec config
is retrieved and appropriate decoder is initialized.

Test: m seahawkuserdebug. Tested media use-cases on seahawk.
Bug: 215240360
Tag: #stability
Change-Id: I76b568a5b09e0cd775de0cdd3434fed216f0205f
parent 14fc0ff7
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -405,13 +405,6 @@ class BtaAvCo {
   */
  const tA2DP_ENCODER_INTERFACE* GetSourceEncoderInterface();

  /**
   * Get the Sink decoder interface for the current codec.
   *
   * @return the Sink decoder interface for the current codec
   */
  const tA2DP_DECODER_INTERFACE* GetSinkDecoderInterface();

  /**
   * Set the codec user configuration.
   *
@@ -1446,8 +1439,8 @@ void BtaAvCo::UpdateMtu(tBTA_AV_HNDL bta_av_handle,
}

bool BtaAvCo::SetActivePeer(const RawAddress& peer_address) {
  VLOG(1) << __func__ << ": peer_address="
          << ADDRESS_TO_LOGGABLE_STR(peer_address);
  LOG(INFO) << __func__
            << ": peer_address=" << ADDRESS_TO_LOGGABLE_STR(peer_address);

  std::lock_guard<std::recursive_mutex> lock(codec_lock_);

@@ -1505,12 +1498,6 @@ const tA2DP_ENCODER_INTERFACE* BtaAvCo::GetSourceEncoderInterface() {
  return A2DP_GetEncoderInterface(codec_config_);
}

const tA2DP_DECODER_INTERFACE* BtaAvCo::GetSinkDecoderInterface() {
  std::lock_guard<std::recursive_mutex> lock(codec_lock_);

  return A2DP_GetDecoderInterface(codec_config_);
}

bool BtaAvCo::SetCodecUserConfig(
    const RawAddress& peer_address,
    const btav_a2dp_codec_config_t& codec_user_config, bool* p_restart_output) {
@@ -2263,10 +2250,6 @@ const tA2DP_ENCODER_INTERFACE* bta_av_co_get_encoder_interface(void) {
  return bta_av_co_cb.GetSourceEncoderInterface();
}

const tA2DP_DECODER_INTERFACE* bta_av_co_get_decoder_interface(void) {
  return bta_av_co_cb.GetSinkDecoderInterface();
}

bool bta_av_co_set_codec_user_config(
    const RawAddress& peer_address,
    const btav_a2dp_codec_config_t& codec_user_config, bool* p_restart_output) {
+0 −6
Original line number Diff line number Diff line
@@ -40,12 +40,6 @@ void bta_av_co_get_peer_params(const RawAddress& peer_addr,
// otherwise NULL.
const tA2DP_ENCODER_INTERFACE* bta_av_co_get_encoder_interface(void);

// Gets the current A2DP decoder interface that can be used to decode received
// A2DP packets - see |tA2DP_DECODER_INTERFACE|.
// Returns the A2DP decoder interface if the current codec is setup, otherwise
// NULL.
const tA2DP_DECODER_INTERFACE* bta_av_co_get_decoder_interface(void);

// Sets the user preferred codec configuration.
// The peer address is |peer_addr|.
// |codec_user_config| contains the preferred codec configuration.
+2 −1
Original line number Diff line number Diff line
@@ -631,7 +631,8 @@ static void btif_a2dp_sink_decoder_update_event(
  btif_a2dp_sink_cb.rx_flush = false;
  APPL_TRACE_DEBUG("%s: reset to Sink role", __func__);

  btif_a2dp_sink_cb.decoder_interface = bta_av_co_get_decoder_interface();
  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;
+3 −3
Original line number Diff line number Diff line
@@ -4035,7 +4035,7 @@ uint8_t btif_av_get_peer_sep(void) {
  }

  uint8_t peer_sep = peer->PeerSep();
  LOG_INFO("Peer %s SEP is %s (%d)",
  BTIF_TRACE_DEBUG("Peer %s SEP is %s (%d)",
                   ADDRESS_TO_LOGGABLE_CSTR(peer->PeerAddress()),
                   (peer_sep == AVDT_TSEP_SRC) ? "Source" : "Sink", peer_sep);
  return peer_sep;
+2 −2
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ constexpr float kMinTrackGain = 0.0f;

void* BtifAvrcpAudioTrackCreate(int trackFreq, int bitsPerSample,
                                int channelCount) {
  LOG_VERBOSE("%s Track.cpp: btCreateTrack freq %d bps %d channel %d ",
              __func__, trackFreq, bitsPerSample, channelCount);
  LOG_INFO("%s Track.cpp: btCreateTrack freq %d bps %d channel %d ", __func__,
           trackFreq, bitsPerSample, channelCount);

  AAudioStreamBuilder* builder;
  AAudioStream* stream;
Loading