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

Commit b58cee4a authored by Limon Mia's avatar Limon Mia
Browse files

BTAudio HAL: Added feature flag for DSA Over LEA

Test: atest VtsHalBluetoothAudioTargetTest
Bug: 270987427
Change-Id: Ifef0b97d20c7c12001b7d04cc7f8ce9da5fb1920
parent 83a9d7f7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
aconfig_declarations {
    name: "btaudiohal_flags",
    package: "com.android.btaudio.hal.flags",
    srcs: ["btaudiohal.aconfig"],
}

cc_aconfig_library {
    name: "btaudiohal_flags_c_lib",
    aconfig_declarations: "btaudiohal_flags",
    vendor: true,
    host_supported: true,
}
+8 −0
Original line number Diff line number Diff line
package: "com.android.btaudio.hal.flags"

flag {
    name: "dsa_lea"
    namespace: "pixel_bluetooth"
    description: "Flag for DSA Over LEA"
    bug: "270987427"
}
+4 −0
Original line number Diff line number Diff line
@@ -63,6 +63,10 @@ cc_library_shared {
        "libhidlbase",
        "libxml2",
        "libflatbuffers-cpp",
        "server_configurable_flags",
    ],
    static_libs: [
        "btaudiohal_flags_c_lib",
    ],
    generated_sources: ["le_audio_codec_capabilities"],
    generated_headers: [
+46 −21
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <android/binder_manager.h>
#include <com_android_btaudio_hal_flags.h>
#include <hardware/audio.h>

#include "BluetoothAudioSession.h"
@@ -36,6 +37,14 @@ static constexpr int kFmqReceiveTimeoutMs =
static constexpr int kWritePollMs = 1;  // polled non-blocking interval
static constexpr int kReadPollMs = 1;   // polled non-blocking interval

static std::string toString(const std::vector<LatencyMode>& latencies) {
  std::stringstream latencyModesStr;
  for (LatencyMode mode : latencies) {
    latencyModesStr << " " << toString(mode);
  }
  return latencyModesStr.str();
}

BluetoothAudioSession::BluetoothAudioSession(const SessionType& session_type)
    : session_type_(session_type), stack_iface_(nullptr), data_mq_(nullptr) {}

@@ -65,6 +74,7 @@ void BluetoothAudioSession::OnSessionStarted(
    stack_iface_ = stack_iface;
    latency_modes_ = latency_modes;
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << " - All LatencyModes=" << toString(latency_modes)
              << ", AudioConfiguration=" << audio_config.toString();
    ReportSessionStatus();
  }
@@ -604,6 +614,7 @@ std::vector<LatencyMode> BluetoothAudioSession::GetSupportedLatencyModes() {
    return std::vector<LatencyMode>();
  }

  if (com::android::btaudio::hal::flags::dsa_lea()) {
    std::vector<LatencyMode> supported_latency_modes;
    if (session_type_ ==
        SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
@@ -622,15 +633,29 @@ std::vector<LatencyMode> BluetoothAudioSession::GetSupportedLatencyModes() {
        }
        if (mode == LatencyMode::DYNAMIC_SPATIAL_AUDIO_SOFTWARE ||
            mode == LatencyMode::DYNAMIC_SPATIAL_AUDIO_HARDWARE) {
        // DSA_SW and DSA_HW only supported for LE_HARDWARE_OFFLOAD_ENC sessions
          // DSA_SW and DSA_HW only supported for LE_HARDWARE_OFFLOAD_ENC
          // sessions
          continue;
        }
        supported_latency_modes.push_back(mode);
      }
    }
    LOG(DEBUG) << __func__ << " - Supported LatencyMode="
               << toString(supported_latency_modes);
    return supported_latency_modes;
  }

  if (low_latency_allowed_) return latency_modes_;
  std::vector<LatencyMode> modes;
  for (LatencyMode mode : latency_modes_) {
    if (mode == LatencyMode::LOW_LATENCY)
      // ignore those low latency mode if Bluetooth stack doesn't allow
      continue;
    modes.push_back(mode);
  }
  return modes;
}

void BluetoothAudioSession::SetLatencyMode(const LatencyMode& latency_mode) {
  std::lock_guard<std::recursive_mutex> guard(mutex_);
  if (!IsSessionReady()) {