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

Commit ca4a03aa authored by kuanyuhuang's avatar kuanyuhuang
Browse files

Support setting BT controller Low Latency mode(1/2)

Handle audio api StartRequest and SetLatencyMode in a2dp to send stream latency
through btif_av to bta event.

Bug: 240637363
Bug: 223126227
Tag: #feature
Ignore-AOSP-First: TM QPR1 feature
Test: test on sink device support dynamic spatial audio
Change-Id: I9ad4a23a58eeca6128a9f04a530ae6c90c773da5
parent 42e7b1d3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ BluetoothAudioCtrlAck A2dpTransport::StartRequest(bool is_low_latency) {
     * procedure is completed, othewise send it now.
     */
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_START;
    btif_av_stream_start();
    btif_av_stream_start_with_latency(is_low_latency);
    if (btif_av_get_peer_sep() != AVDT_TSEP_SRC) {
      LOG(INFO) << __func__ << ": accepted";
      return a2dp_ack_to_bt_audio_ctrl_ack(A2DP_CTRL_ACK_PENDING);
@@ -138,6 +138,10 @@ void A2dpTransport::StopRequest() {
  btif_av_stream_stop(RawAddress::kEmpty);
}

void A2dpTransport::SetLowLatency(bool is_low_latency) {
  btif_av_set_low_latency(is_low_latency);
}

bool A2dpTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns,
                                            uint64_t* total_bytes_read,
                                            timespec* data_position) {
+3 −1
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ class A2dpTransport

  void StopRequest() override;

  void SetLowLatency(bool is_low_latency) override;

  bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
                               uint64_t* total_bytes_read,
                               timespec* data_position) override;
+2 −1
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ ndk::ScopedAStatus BluetoothAudioPortImpl::setLatencyMode(
    LatencyMode latency_mode) {
  bool is_low_latency = latency_mode == LatencyMode::LOW_LATENCY ? true : false;
  invoke_switch_buffer_size_cb(is_low_latency);
  transport_instance_->SetLowLatency(is_low_latency);
  return ndk::ScopedAStatus::ok();
}

+3 −1
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ class HearingAidTransport
    }
  }

  void SetLowLatency(bool is_low_latency) override {}

  bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
                               uint64_t* total_bytes_read,
                               timespec* data_position) override {
+11 −1
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ void LeAudioTransport::StopRequest() {
  }
}

void LeAudioTransport::SetLowLatency(bool is_low_latency) {}

bool LeAudioTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns,
                                               uint64_t* total_bytes_processed,
                                               timespec* data_position) {
@@ -244,6 +246,10 @@ BluetoothAudioCtrlAck LeAudioSinkTransport::SuspendRequest() {

void LeAudioSinkTransport::StopRequest() { transport_->StopRequest(); }

void LeAudioSinkTransport::SetLowLatency(bool is_low_latency) {
  transport_->SetLowLatency(is_low_latency);
}

bool LeAudioSinkTransport::GetPresentationPosition(
    uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read,
    timespec* data_position) {
@@ -327,6 +333,10 @@ BluetoothAudioCtrlAck LeAudioSourceTransport::SuspendRequest() {

void LeAudioSourceTransport::StopRequest() { transport_->StopRequest(); }

void LeAudioSourceTransport::SetLowLatency(bool is_low_latency) {
  transport_->SetLowLatency(is_low_latency);
}

bool LeAudioSourceTransport::GetPresentationPosition(
    uint64_t* remote_delay_report_ns, uint64_t* total_bytes_written,
    timespec* data_position) {
Loading