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

Commit 096f558c authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge changes from topic "bt-le-audio-dsa" into main

* changes:
  Change CIG parameters for DSA
  Updating LE audio tests with DSA changes
  Set supported latency modes based on the PAC characteristics
  Allow audio AIDL clients to set all latency modes support
  Add support for new LatencyMode enum
  Adding feature flag for Dynamic Spatial Audio for LE Audio
parents f55d5c59 6dc7ff42
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -41,3 +41,10 @@ flag {
    description: "Enables support for the multicodec AIDL"
    bug: "313054645"
}

flag {
    name: "leaudio_dynamic_spatial_audio"
    namespace: "bluetooth"
    description: "Support Dynamic Spatial Audio for LE Audio"
    bug: "309665975"
}
+12 −3
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);
}

@@ -485,7 +486,11 @@ void start_session() {
    LOG(ERROR) << __func__ << ": BluetoothAudio HAL is not enabled";
    return;
  }
  active_hal_interface->SetLowLatencyModeAllowed(is_low_latency_mode_allowed);
  std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};
  if (is_low_latency_mode_allowed) {
    latency_modes.push_back(LatencyMode::LOW_LATENCY);
  }
  active_hal_interface->SetAllowedLatencyModes(latency_modes);
  active_hal_interface->StartSession();
}

@@ -575,7 +580,11 @@ void set_low_latency_mode_allowed(bool allowed) {
    LOG(ERROR) << __func__ << ": BluetoothAudio HAL is not enabled";
    return;
  }
  active_hal_interface->SetLowLatencyModeAllowed(allowed);
  std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};
  if (is_low_latency_mode_allowed) {
    latency_modes.push_back(LatencyMode::LOW_LATENCY);
  }
  active_hal_interface->SetAllowedLatencyModes(latency_modes);
}

}  // namespace a2dp
+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();
}

+22 −11
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface(
      provider_factory_(nullptr),
      session_started_(false),
      data_mq_(nullptr),
      transport_(instance) {
      transport_(instance),
      latency_modes_({LatencyMode::FREE}) {
  death_recipient_ = ::ndk::ScopedAIBinder_DeathRecipient(
      AIBinder_DeathRecipient_new(binderDiedCallbackAidl));
}
@@ -241,18 +242,31 @@ bool BluetoothAudioClientInterface::UpdateAudioConfig(
  return true;
}

bool BluetoothAudioClientInterface::SetLowLatencyModeAllowed(bool allowed) {
  is_low_latency_allowed_ = allowed;
bool BluetoothAudioClientInterface::SetAllowedLatencyModes(
    std::vector<LatencyMode> latency_modes) {
  if (provider_ == nullptr) {
    LOG(INFO) << __func__ << ": BluetoothAudioHal nullptr";
    return false;
  }

  /* Ensure that FREE is always included and remove duplicates if any */
  std::set<LatencyMode> temp_set(latency_modes.begin(), latency_modes.end());
  temp_set.insert(LatencyMode::FREE);
  latency_modes_.clear();
  latency_modes_.assign(temp_set.begin(), temp_set.end());

  for (auto latency_mode : latency_modes) {
    LOG(INFO) << "Latency mode allowed: "
              << ::aidl::android::hardware::bluetooth::audio::toString(
                     latency_mode);
  }

  /* Low latency mode is used if modes other than FREE are present */
  bool allowed = (latency_modes_.size() > 1);
  auto aidl_retval = provider_->setLowLatencyModeAllowed(allowed);
  if (!aidl_retval.isOk()) {
    LOG(WARNING) << __func__ << ": BluetoothAudioHal is not ready: "
               << aidl_retval.getDescription()
               << ". is_low_latency_allowed_ is saved "
                 << aidl_retval.getDescription() << ". latency_modes_ is saved "
                 << "and it will be sent to BluetoothAudioHal at StartSession.";
  }
  return true;
@@ -275,12 +289,9 @@ int BluetoothAudioClientInterface::StartSession() {

  std::unique_ptr<DataMQ> data_mq;
  DataMQDesc mq_desc;
  std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};
  if (is_low_latency_allowed_) {
    latency_modes.push_back(LatencyMode::LOW_LATENCY);
  }

  auto aidl_retval = provider_->startSession(
      stack_if, transport_->GetAudioConfiguration(), latency_modes, &mq_desc);
      stack_if, transport_->GetAudioConfiguration(), latency_modes_, &mq_desc);
  if (!aidl_retval.isOk()) {
    if (aidl_retval.getExceptionCode() == EX_ILLEGAL_ARGUMENT) {
      LOG(ERROR) << __func__ << ": BluetoothAudioHal Error: "
Loading