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

Commit ca0c9442 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ic9143b7c,I3e97ff6c,I481a2081 am: 34527e5f am: 9c23208d am: 33841727

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1815494

Change-Id: Icb86091cd39567fa6a4e062929337bdb39986e7a
parents 855a557d 33841727
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ bool a2dp_get_selected_hal_codec_config(CodecConfiguration* codec_config) {
  RawAddress peer_addr = btif_av_source_active_peer();
  tA2DP_ENCODER_INIT_PEER_PARAMS peer_param;
  bta_av_co_get_peer_params(peer_addr, &peer_param);
  int effectiveMtu = a2dp_config->getEffectiveMtu();
  int effectiveMtu = bta_av_co_get_encoder_effective_frame_size();
  if (effectiveMtu > 0 && effectiveMtu < peer_param.peer_mtu) {
    codec_config->peerMtu = effectiveMtu;
  } else {
+7 −0
Original line number Diff line number Diff line
@@ -3044,6 +3044,13 @@ void bta_av_vendor_offload_start(tBTA_AV_SCB* p_scb,
  ARRAY_TO_STREAM(p_param, offload_start->codec_info,
                  (int8_t)sizeof(offload_start->codec_info));
  p_scb->offload_started = true;
  LOG_INFO(
      "codec: %#x, sample rate: %#x, bit depth: %#x, channel: %#x, bitrate: "
      "%#x, ACL: %#x, L2CAP: %#x, MTU: %#x",
      offload_start->codec_type, offload_start->sample_rate,
      offload_start->bits_per_sample, offload_start->ch_mode,
      offload_start->encoded_audio_bitrate, offload_start->acl_hdl,
      offload_start->l2c_rcid, offload_start->mtu);
  BTM_VendorSpecificCommand(HCI_CONTROLLER_A2DP, p_param - param,
                            param, offload_vendor_callback);
}
+17 −0
Original line number Diff line number Diff line
@@ -428,6 +428,13 @@ class BtaAvCo {
   */
  bool SetCodecAudioConfig(const btav_a2dp_codec_config_t& codec_audio_config);

  /**
   * Get the Source encoder maximum frame size for the current codec.
   *
   * @return the effective frame size for the current codec
   */
  int GetSourceEncoderEffectiveFrameSize();

  /**
   * Report the source codec state for a peer
   *
@@ -1642,6 +1649,12 @@ bool BtaAvCo::SetCodecAudioConfig(
  return true;
}

int BtaAvCo::GetSourceEncoderEffectiveFrameSize() {
  std::lock_guard<std::recursive_mutex> lock(codec_lock_);

  return A2DP_GetEecoderEffectiveFrameSize(codec_config_);
}

bool BtaAvCo::ReportSourceCodecState(BtaAvCoPeer* p_peer) {
  btav_a2dp_codec_config_t codec_config;
  std::vector<btav_a2dp_codec_config_t> codecs_local_capabilities;
@@ -2201,6 +2214,10 @@ bool bta_av_co_set_codec_audio_config(
  return bta_av_co_cb.SetCodecAudioConfig(codec_audio_config);
}

int bta_av_co_get_encoder_effective_frame_size() {
  return bta_av_co_cb.GetSourceEncoderEffectiveFrameSize();
}

btav_a2dp_scmst_info_t bta_av_co_get_scmst_info(
    const RawAddress& peer_address) {
  BtaAvCoPeer* p_peer = bta_av_co_cb.FindPeer(peer_address);
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,10 @@ A2dpCodecConfig* bta_av_get_a2dp_current_codec(void);
A2dpCodecConfig* bta_av_get_a2dp_peer_current_codec(
    const RawAddress& peer_address);

// Gets the A2DP effective frame size from the current encoder.
// Returns the effective frame size if the encoder is configured, otherwise 0.
int bta_av_co_get_encoder_effective_frame_size();

// Dump A2DP codec debug-related information for the A2DP module.
// |fd| is the file descriptor to use for writing the ASCII formatted
// information.
+21 −0
Original line number Diff line number Diff line
@@ -249,6 +249,8 @@ static void btif_a2dp_source_audio_tx_flush_event(void);
static void btif_a2dp_source_setup_codec(const RawAddress& peer_addr);
static void btif_a2dp_source_setup_codec_delayed(
    const RawAddress& peer_address);
static void btif_a2dp_source_cleanup_codec();
static void btif_a2dp_source_cleanup_codec_delayed();
static void btif_a2dp_source_encoder_user_config_update_event(
    const RawAddress& peer_address,
    const std::vector<btav_a2dp_codec_config_t>& codec_user_preferences,
@@ -452,6 +454,7 @@ bool btif_a2dp_source_end_session(const RawAddress& peer_address) {
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE,
      base::Bind(&btif_a2dp_source_end_session_delayed, peer_address));
  btif_a2dp_source_cleanup_codec();
  return true;
}

@@ -593,6 +596,24 @@ static void btif_a2dp_source_setup_codec_delayed(
  }
}

static void btif_a2dp_source_cleanup_codec() {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());
  if (btif_a2dp_source_is_streaming()) {
    // Must stop media task first before cleaning up the encoder
    btif_a2dp_source_stop_audio_req();
  }
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_cleanup_codec_delayed));
}

static void btif_a2dp_source_cleanup_codec_delayed() {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());
  if (btif_a2dp_source_cb.encoder_interface != nullptr) {
    btif_a2dp_source_cb.encoder_interface->encoder_cleanup();
    btif_a2dp_source_cb.encoder_interface = nullptr;
  }
}

void btif_a2dp_source_start_audio_req(void) {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());

Loading