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

Commit 39145fd5 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Set supported latency modes based on the PAC characteristics

Set appropriate supported latency modes based on whether the Google
vendor specific headtracking codec was found in the PAC service.

Test: m com.android.btservices
Bug: 304840881
Bug: 270983595
Change-Id: I053ca7c92084fc4d0e6a58398043e0a7fe6d2615
parent bdf23e56
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -244,19 +244,25 @@ bool BluetoothAudioClientInterface::UpdateAudioConfig(

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());

  bool allowed = (latency_modes_.size() > 1);

  if (provider_ == nullptr) {
    LOG(INFO) << __func__ << ": BluetoothAudioHal nullptr";
    return false;
  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: "
+29 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ using AudioConfiguration_2_1 =
    ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration;
using AudioConfigurationAIDL =
    ::aidl::android::hardware::bluetooth::audio::AudioConfiguration;
using ::aidl::android::hardware::bluetooth::audio::LatencyMode;
using ::aidl::android::hardware::bluetooth::audio::LeAudioCodecConfiguration;

using ::le_audio::CodecManager;
@@ -852,6 +853,34 @@ bool LeAudioClientInterface::ReleaseSource(
  return true;
}

void LeAudioClientInterface::SetAllowedDsaModes(DsaModes dsa_modes) {
  if (HalVersionManager::GetHalTransport() ==
      BluetoothAudioHalTransport::AIDL) {
    std::vector<LatencyMode> latency_modes;
    for (auto dsa_mode : dsa_modes) {
      switch (dsa_mode) {
        case DsaMode::DISABLED:
          latency_modes.push_back(LatencyMode::FREE);
          break;
        case DsaMode::ACL:
          latency_modes.push_back(LatencyMode::LOW_LATENCY);
          break;
        case DsaMode::ISO_SW:
          latency_modes.push_back(LatencyMode::DYNAMIC_SPATIAL_AUDIO_SOFTWARE);
          break;
        case DsaMode::ISO_HW:
          latency_modes.push_back(LatencyMode::DYNAMIC_SPATIAL_AUDIO_HARDWARE);
          break;
        default:
          LOG(WARNING) << "Unsupported latency mode ignored: " << (int)dsa_mode;
          break;
      }
    }
    aidl::le_audio::LeAudioSourceTransport::interface->SetAllowedLatencyModes(
        latency_modes);
  }
}

}  // namespace le_audio
}  // namespace audio
}  // namespace bluetooth
+6 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ namespace audio {
namespace le_audio {

using ::le_audio::DsaMode;
using ::le_audio::DsaModes;

enum class StartRequestState {
  IDLE = 0x00,
@@ -158,7 +159,11 @@ class LeAudioClientInterface {
  // Release source interface if belongs to LE audio client interface
  bool ReleaseSource(Source* source);

  // Get interface, if previously not initialized - it'll initialize singleton.
  // Sets Dynamic Spatial Audio modes supported by the remote device
  void SetAllowedDsaModes(DsaModes dsa_modes);

  // Get interface, if previously not initialized - it'll initialize
  // singleton.
  static LeAudioClientInterface* Get();

 private:
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ bool LeAudioClientInterface::ReleaseSource(
  return false;
}

void LeAudioClientInterface::SetAllowedDsaModes(DsaModes dsa_modes) { return; }

}  // namespace le_audio
}  // namespace audio
}  // namespace bluetooth
+4 −2
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ class LeAudioSinkAudioHalClient {

  virtual ~LeAudioSinkAudioHalClient() = default;
  virtual bool Start(const LeAudioCodecConfiguration& codecConfiguration,
                     Callbacks* audioReceiver) = 0;
                     Callbacks* audioReceiver,
                     DsaModes dsa_modes = {DsaMode::DISABLED}) = 0;
  virtual void Stop() = 0;
  virtual size_t SendData(uint8_t* data, uint16_t size) = 0;

@@ -152,7 +153,8 @@ class LeAudioSourceAudioHalClient {

  virtual ~LeAudioSourceAudioHalClient() = default;
  virtual bool Start(const LeAudioCodecConfiguration& codecConfiguration,
                     Callbacks* audioReceiver) = 0;
                     Callbacks* audioReceiver,
                     DsaModes dsa_modes = {DsaMode::DISABLED}) = 0;
  virtual void Stop() = 0;
  virtual size_t SendData(uint8_t* data, uint16_t size) { return 0; }
  virtual void ConfirmStreamingRequest() = 0;
Loading