From b58cee4af7fe8a3c9998ce44e84a69189f51c3df Mon Sep 17 00:00:00 2001 From: Limon Mia Date: Fri, 1 Dec 2023 12:16:00 +0000 Subject: [PATCH] BTAudio HAL: Added feature flag for DSA Over LEA Test: atest VtsHalBluetoothAudioTargetTest Bug: 270987427 Change-Id: Ifef0b97d20c7c12001b7d04cc7f8ce9da5fb1920 --- bluetooth/audio/flags/Android.bp | 12 ++++ bluetooth/audio/flags/btaudiohal.aconfig | 8 +++ bluetooth/audio/utils/Android.bp | 4 ++ .../aidl_session/BluetoothAudioSession.cpp | 69 +++++++++++++------ 4 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 bluetooth/audio/flags/Android.bp create mode 100644 bluetooth/audio/flags/btaudiohal.aconfig diff --git a/bluetooth/audio/flags/Android.bp b/bluetooth/audio/flags/Android.bp new file mode 100644 index 0000000000..0d18a4d546 --- /dev/null +++ b/bluetooth/audio/flags/Android.bp @@ -0,0 +1,12 @@ +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, +} diff --git a/bluetooth/audio/flags/btaudiohal.aconfig b/bluetooth/audio/flags/btaudiohal.aconfig new file mode 100644 index 0000000000..763777ea6a --- /dev/null +++ b/bluetooth/audio/flags/btaudiohal.aconfig @@ -0,0 +1,8 @@ +package: "com.android.btaudio.hal.flags" + +flag { + name: "dsa_lea" + namespace: "pixel_bluetooth" + description: "Flag for DSA Over LEA" + bug: "270987427" +} diff --git a/bluetooth/audio/utils/Android.bp b/bluetooth/audio/utils/Android.bp index f5f8163a92..c0817f54e1 100644 --- a/bluetooth/audio/utils/Android.bp +++ b/bluetooth/audio/utils/Android.bp @@ -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: [ diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index 3519ace1f9..c05750538d 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #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& 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,31 +614,46 @@ std::vector BluetoothAudioSession::GetSupportedLatencyModes() { return std::vector(); } - std::vector supported_latency_modes; - if (session_type_ == - SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { - for (LatencyMode mode : latency_modes_) { - if (mode == LatencyMode::LOW_LATENCY) { - // LOW_LATENCY is not supported for LE_HARDWARE_OFFLOAD_ENC sessions - continue; + if (com::android::btaudio::hal::flags::dsa_lea()) { + std::vector supported_latency_modes; + if (session_type_ == + SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { + for (LatencyMode mode : latency_modes_) { + if (mode == LatencyMode::LOW_LATENCY) { + // LOW_LATENCY is not supported for LE_HARDWARE_OFFLOAD_ENC sessions + continue; + } + supported_latency_modes.push_back(mode); + } + } else { + for (LatencyMode mode : latency_modes_) { + if (!low_latency_allowed_ && mode == LatencyMode::LOW_LATENCY) { + // ignore LOW_LATENCY mode if Bluetooth stack doesn't allow + continue; + } + 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 + continue; + } + supported_latency_modes.push_back(mode); } - supported_latency_modes.push_back(mode); - } - } else { - for (LatencyMode mode : latency_modes_) { - if (!low_latency_allowed_ && mode == LatencyMode::LOW_LATENCY) { - // ignore LOW_LATENCY mode if Bluetooth stack doesn't allow - continue; - } - 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 - continue; - } - supported_latency_modes.push_back(mode); } + LOG(DEBUG) << __func__ << " - Supported LatencyMode=" + << toString(supported_latency_modes); + return supported_latency_modes; } - return supported_latency_modes; + + if (low_latency_allowed_) return latency_modes_; + std::vector 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) {