AudioPolicyManager: add support for Bluetooth LE audio codec selection
Add support for Bluetooth LE audio codec reconfiguration similarly to
what is supported for A2DP.
Bug: 309909149
Test: connect BT LE device and check correct codec selection
Change-Id: I1759314fcf0e757db617980aa2129e8bd8af53c5
diff --git a/media/libaudiohal/impl/DeviceHalAidl.cpp b/media/libaudiohal/impl/DeviceHalAidl.cpp
index a58ce1b..6a6557c 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalAidl.cpp
@@ -267,6 +267,9 @@
if (status_t status = filterAndRetrieveBtA2dpParameters(parameterKeys, &result); status != OK) {
ALOGW("%s: filtering or retrieving BT A2DP parameters failed: %d", __func__, status);
}
+ if (status_t status = filterAndRetrieveBtLeParameters(parameterKeys, &result); status != OK) {
+ ALOGW("%s: filtering or retrieving BT LE parameters failed: %d", __func__, status);
+ }
*values = result.toString();
return parseAndGetVendorParameters(mVendorExt, mModule, parameterKeys, values);
}
@@ -988,6 +991,23 @@
return OK;
}
+status_t DeviceHalAidl::filterAndRetrieveBtLeParameters(
+ AudioParameter &keys, AudioParameter *result) {
+ if (String8 key = String8(AudioParameter::keyReconfigLeSupported); keys.containsKey(key)) {
+ keys.remove(key);
+ if (mBluetoothLe != nullptr) {
+ bool supports;
+ RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
+ mBluetoothLe->supportsOffloadReconfiguration(&supports)));
+ result->addInt(key, supports ? 1 : 0);
+ } else {
+ ALOGI("%s: no mBluetoothLe on %s", __func__, mInstance.c_str());
+ result->addInt(key, 0);
+ }
+ }
+ return OK;
+}
+
status_t DeviceHalAidl::filterAndUpdateBtA2dpParameters(AudioParameter ¶meters) {
std::optional<bool> a2dpEnabled;
std::optional<std::vector<VendorParameter>> reconfigureOffload;
@@ -1069,6 +1089,7 @@
status_t DeviceHalAidl::filterAndUpdateBtLeParameters(AudioParameter ¶meters) {
std::optional<bool> leEnabled;
+ std::optional<std::vector<VendorParameter>> reconfigureOffload;
(void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
parameters, String8(AudioParameter::keyBtLeSuspended),
[&leEnabled](const String8& trueOrFalse) {
@@ -1083,9 +1104,27 @@
AudioParameter::keyBtLeSuspended, trueOrFalse.c_str());
return BAD_VALUE;
}));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyReconfigLe),
+ [&](const String8& value) -> status_t {
+ if (mVendorExt != nullptr) {
+ std::vector<VendorParameter> result;
+ RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
+ mVendorExt->parseBluetoothLeReconfigureOffload(
+ std::string(value.c_str()), &result)));
+ reconfigureOffload = std::move(result);
+ } else {
+ reconfigureOffload = std::vector<VendorParameter>();
+ }
+ return OK;
+ }));
if (mBluetoothLe != nullptr && leEnabled.has_value()) {
return statusTFromBinderStatus(mBluetoothLe->setEnabled(leEnabled.value()));
}
+ if (mBluetoothLe != nullptr && reconfigureOffload.has_value()) {
+ return statusTFromBinderStatus(mBluetoothLe->reconfigureOffload(
+ reconfigureOffload.value()));
+ }
return OK;
}
diff --git a/media/libaudiohal/impl/DeviceHalAidl.h b/media/libaudiohal/impl/DeviceHalAidl.h
index 9493e47..f705db7 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.h
+++ b/media/libaudiohal/impl/DeviceHalAidl.h
@@ -207,6 +207,7 @@
~DeviceHalAidl() override = default;
status_t filterAndRetrieveBtA2dpParameters(AudioParameter &keys, AudioParameter *result);
+ status_t filterAndRetrieveBtLeParameters(AudioParameter &keys, AudioParameter *result);
status_t filterAndUpdateBtA2dpParameters(AudioParameter ¶meters);
status_t filterAndUpdateBtHfpParameters(AudioParameter ¶meters);
status_t filterAndUpdateBtLeParameters(AudioParameter ¶meters);