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

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

Merge "Route A2DP Traffic" into main am: 9b2aadc4

parents 562dcf7e 9b2aadc4
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -132,12 +132,12 @@ bool StartRequest() {
    return false;
  }

  if (btif_av_stream_started_ready()) {
  if (btif_av_stream_started_ready(A2dpType::kSource)) {
    // Already started, ACK back immediately.
    a2dp_data_path_open();
    return true;
  }
  if (btif_av_stream_ready()) {
  if (btif_av_stream_ready(A2dpType::kSource)) {
    a2dp_data_path_open();
    /*
     * Post start event and wait for audio path to open.
@@ -145,8 +145,8 @@ bool StartRequest() {
     * procedure is completed.
     */
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_START;
    btif_av_stream_start();
    if (btif_av_get_peer_sep() != AVDT_TSEP_SRC) {
    btif_av_stream_start(A2dpType::kSource);
    if (btif_av_get_peer_sep(A2dpType::kSource) != AVDT_TSEP_SRC) {
      LOG_INFO("%s: accepted", __func__);
      return true;  // NOTE: The request is placed, but could still fail.
    }
@@ -159,9 +159,9 @@ bool StartRequest() {

// Invoked by audio server when audio streaming is done.
bool StopRequest() {
  if (btif_av_get_peer_sep() == AVDT_TSEP_SNK &&
      !btif_av_stream_started_ready()) {
    btif_av_clear_remote_suspend_flag();
  if (btif_av_get_peer_sep(A2dpType::kSource) == AVDT_TSEP_SNK &&
      !btif_av_stream_started_ready(A2dpType::kSource)) {
    btif_av_clear_remote_suspend_flag(A2dpType::kSource);
    return true;
  }
  LOG_INFO("%s: handling", __func__);
@@ -175,7 +175,7 @@ bool SuspendRequest() {
    LOG_WARN("%s: busy in pending_cmd=%u", __func__, a2dp_pending_cmd_);
    return false;
  }
  if (!btif_av_stream_started_ready()) {
  if (!btif_av_stream_started_ready(A2dpType::kSource)) {
    LOG_WARN("%s: AV stream is not started", __func__);
    return false;
  }
+8 −8
Original line number Diff line number Diff line
@@ -85,11 +85,11 @@ BluetoothAudioCtrlAck A2dpTransport::StartRequest(bool is_low_latency) {
    return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_INCALL_FAILURE);
  }

  if (btif_av_stream_started_ready()) {
  if (btif_av_stream_started_ready(A2dpType::kSource)) {
    // Already started, ACK back immediately.
    return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_SUCCESS);
  }
  if (btif_av_stream_ready()) {
  if (btif_av_stream_ready(A2dpType::kSource)) {
    // check if codec needs to be switched prior to stream start
    invoke_switch_codec_cb(is_low_latency);
    /*
@@ -99,7 +99,7 @@ BluetoothAudioCtrlAck A2dpTransport::StartRequest(bool is_low_latency) {
     */
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_START;
    btif_av_stream_start_with_latency(is_low_latency);
    if (btif_av_get_peer_sep() != AVDT_TSEP_SRC) {
    if (btif_av_get_peer_sep(A2dpType::kSource) != AVDT_TSEP_SRC) {
      LOG(INFO) << __func__ << ": accepted";
      return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_PENDING);
    }
@@ -120,7 +120,7 @@ BluetoothAudioCtrlAck A2dpTransport::SuspendRequest() {
    return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_FAILURE);
  }
  // Local suspend
  if (btif_av_stream_started_ready()) {
  if (btif_av_stream_started_ready(A2dpType::kSource)) {
    LOG(INFO) << __func__ << ": accepted";
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_SUSPEND;
    btif_av_stream_suspend();
@@ -130,14 +130,14 @@ BluetoothAudioCtrlAck A2dpTransport::SuspendRequest() {
   * audioflinger close the channel. This can happen if we are
   * remotely suspended, clear REMOTE SUSPEND flag.
   */
  btif_av_clear_remote_suspend_flag();
  btif_av_clear_remote_suspend_flag(A2dpType::kSource);
  return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_SUCCESS);
}

void A2dpTransport::StopRequest() {
  if (btif_av_get_peer_sep() == AVDT_TSEP_SNK &&
      !btif_av_stream_started_ready()) {
    btif_av_clear_remote_suspend_flag();
  if (btif_av_get_peer_sep(A2dpType::kSource) == AVDT_TSEP_SNK &&
      !btif_av_stream_started_ready(A2dpType::kSource)) {
    btif_av_clear_remote_suspend_flag(A2dpType::kSource);
    return;
  }
  LOG(INFO) << __func__ << ": handling";
+9 −9
Original line number Diff line number Diff line
@@ -80,19 +80,19 @@ class A2dpTransport
      return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_INCALL_FAILURE);
    }

    if (btif_av_stream_started_ready()) {
    if (btif_av_stream_started_ready(A2dpType::kSource)) {
      // Already started, ACK back immediately.
      return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_SUCCESS);
    }
    if (btif_av_stream_ready()) {
    if (btif_av_stream_ready(A2dpType::kSource)) {
      /*
       * Post start event and wait for audio path to open.
       * If we are the source, the ACK will be sent after the start
       * procedure is completed, othewise send it now.
       */
      a2dp_pending_cmd_ = A2DP_CTRL_CMD_START;
      btif_av_stream_start();
      if (btif_av_get_peer_sep() != AVDT_TSEP_SRC) {
      btif_av_stream_start(A2dpType::kSource);
      if (btif_av_get_peer_sep(A2dpType::kSource) != AVDT_TSEP_SRC) {
        LOG(INFO) << __func__ << ": accepted";
        return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_PENDING);
      }
@@ -113,7 +113,7 @@ class A2dpTransport
      return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_FAILURE);
    }
    // Local suspend
    if (btif_av_stream_started_ready()) {
    if (btif_av_stream_started_ready(A2dpType::kSource)) {
      LOG(INFO) << __func__ << ": accepted";
      a2dp_pending_cmd_ = A2DP_CTRL_CMD_SUSPEND;
      btif_av_stream_suspend();
@@ -123,14 +123,14 @@ class A2dpTransport
     * audioflinger close the channel. This can happen if we are
     * remotely suspended, clear REMOTE SUSPEND flag.
     */
    btif_av_clear_remote_suspend_flag();
    btif_av_clear_remote_suspend_flag(A2dpType::kSource);
    return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_SUCCESS);
  }

  void StopRequest() override {
    if (btif_av_get_peer_sep() == AVDT_TSEP_SNK &&
        !btif_av_stream_started_ready()) {
      btif_av_clear_remote_suspend_flag();
    if (btif_av_get_peer_sep(A2dpType::kSource) == AVDT_TSEP_SNK &&
        !btif_av_stream_started_ready(A2dpType::kSource)) {
      btif_av_clear_remote_suspend_flag(A2dpType::kSource);
      return;
    }
    LOG(INFO) << __func__ << ": handling";
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#define LOG_TAG "bt_bta_av"

#include <base/logging.h>
#include <bluetooth/log.h>

#include <cstdint>
@@ -646,6 +645,7 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
      btav_a2dp_codec_index_t codec_index =
          static_cast<btav_a2dp_codec_index_t>(i);
      if (!bta_av_co_is_supported_codec(codec_index)) {
        log::warn("Skipping the codec index for codec index {}", i);
        continue;
      }
      if (!(*bta_av_a2dp_cos.init)(codec_index, &avdtp_stream_config.cfg)) {
+5 −4
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ tA2DP_STATUS BtaAvCo::ProcessSourceGetConfig(
      return A2DP_FAIL;
    }
  } else {
    if (btif_av_peer_prefers_mandatory_codec(p_peer->addr)) {
    if (btif_av_peer_prefers_mandatory_codec(p_peer->addr, A2dpType::kSource)) {
      // Apply user preferred codec directly before first codec selected.
      p_sink = peer_cache_->FindPeerSink(
          p_peer, BTAV_A2DP_CODEC_INDEX_SOURCE_SBC, ContentProtectFlag());
@@ -739,7 +739,7 @@ void BtaAvCo::ProcessAudioDelay(tBTA_AV_HNDL bta_av_handle,
  log::verbose("peer {} bta_av_handle: 0x{:x} delay:0x{:x}",
               ADDRESS_TO_LOGGABLE_CSTR(peer_address), bta_av_handle, delay);

  btif_av_set_audio_delay(peer_address, delay);
  btif_av_set_audio_delay(peer_address, delay, A2dpType::kSource);
}

void BtaAvCo::UpdateMtu(tBTA_AV_HNDL bta_av_handle,
@@ -833,9 +833,10 @@ void BtaAvCo::GetPeerEncoderParameters(
    if (p_peer->mtu < min_mtu) min_mtu = p_peer->mtu;
  }
  p_peer_params->peer_mtu = min_mtu;
  p_peer_params->is_peer_edr = btif_av_is_peer_edr(peer_address);
  p_peer_params->is_peer_edr =
      btif_av_is_peer_edr(peer_address, A2dpType::kSource);
  p_peer_params->peer_supports_3mbps =
      btif_av_peer_supports_3mbps(peer_address);
      btif_av_peer_supports_3mbps(peer_address, A2dpType::kSource);
  log::verbose(
      "peer_address={} peer_mtu={} is_peer_edr={} peer_supports_3mbps={}",
      ADDRESS_TO_LOGGABLE_CSTR(peer_address), p_peer_params->peer_mtu,
Loading