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

Commit c559c9f7 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Add support for new LatencyMode enum

Test: mmm packages/modules/Bluetooth
Bug: 304840881
Change-Id: Ia6a7a9f6cbd27e2aa276b45ed3b7b457bf62b4ca
parent 2a9c2fd7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ void A2dpTransport::StopRequest() {
  btif_av_stream_stop(RawAddress::kEmpty);
}

void A2dpTransport::SetLowLatency(bool is_low_latency) {
void A2dpTransport::SetLatencyMode(LatencyMode latency_mode) {
  bool is_low_latency = latency_mode == LatencyMode::LOW_LATENCY ? true : false;
  btif_av_set_low_latency(is_low_latency);
}

+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ namespace a2dp {

namespace {

using ::bluetooth::audio::aidl::LatencyMode;

BluetoothAudioCtrlAck a2dp_ack_to_bt_audio_ctrl_ack(tA2DP_CTRL_ACK ack);

// Provide call-in APIs for the Bluetooth Audio HAL
@@ -39,7 +41,7 @@ class A2dpTransport

  void StopRequest() override;

  void SetLowLatency(bool is_low_latency) override;
  void SetLatencyMode(LatencyMode latency_mode) override;

  bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
                               uint64_t* total_bytes_read,
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,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);
  transport_instance_->SetLatencyMode(latency_mode);
  return ndk::ScopedAStatus::ok();
}

+2 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ using ::aidl::android::hardware::bluetooth::audio::ChannelMode;
using ::aidl::android::hardware::bluetooth::audio::CodecType;
using ::bluetooth::audio::aidl::AudioConfiguration;
using ::bluetooth::audio::aidl::BluetoothAudioCtrlAck;
using ::bluetooth::audio::aidl::LatencyMode;
using ::bluetooth::audio::aidl::PcmConfiguration;
using ::bluetooth::audio::aidl::SessionType;
using ::bluetooth::audio::aidl::hearing_aid::StreamCallbacks;
@@ -74,7 +75,7 @@ class HearingAidTransport
    }
  }

  void SetLowLatency(bool is_low_latency) override {}
  void SetLatencyMode(LatencyMode latency_mode) override {}

  bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
                               uint64_t* total_bytes_read,
+24 −6
Original line number Diff line number Diff line
@@ -124,7 +124,25 @@ void LeAudioTransport::StopRequest() {
  }
}

void LeAudioTransport::SetLowLatency(bool is_low_latency) {}
void LeAudioTransport::SetLatencyMode(LatencyMode latency_mode) {
  switch (latency_mode) {
    case LatencyMode::FREE:
      dsa_mode_ = DsaMode::DISABLED;
      break;
    case LatencyMode::LOW_LATENCY:
      dsa_mode_ = DsaMode::ACL;
      break;
    case LatencyMode::DYNAMIC_SPATIAL_AUDIO_SOFTWARE:
      dsa_mode_ = DsaMode::ISO_SW;
      break;
    case LatencyMode::DYNAMIC_SPATIAL_AUDIO_HARDWARE:
      dsa_mode_ = DsaMode::ISO_HW;
      break;
    default:
      LOG(WARNING) << ", invalid latency mode: " << (int)latency_mode;
      break;
  }
}

bool LeAudioTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns,
                                               uint64_t* total_bytes_processed,
@@ -152,7 +170,7 @@ void LeAudioTransport::SourceMetadataChanged(
    return;
  }

  stream_cb_.on_metadata_update_(source_metadata);
  stream_cb_.on_metadata_update_(source_metadata, dsa_mode_);
}

void LeAudioTransport::SinkMetadataChanged(
@@ -280,8 +298,8 @@ BluetoothAudioCtrlAck LeAudioSinkTransport::SuspendRequest() {

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

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

bool LeAudioSinkTransport::GetPresentationPosition(
@@ -370,8 +388,8 @@ BluetoothAudioCtrlAck LeAudioSourceTransport::SuspendRequest() {

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

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

bool LeAudioSourceTransport::GetPresentationPosition(
Loading