AudioPolicy: EngineConfigurable: PFW 64 bits inclusive criterion
This CL allows to overcome limitation of encoding Audio devices
as an inclusive criterion (aka bitfield) by migrating from 32 to 64bits.
This CL adapts also all the automatic script that parses header file
to build criteria / criterion types.
Bug: 189469490
Test: make
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: Ib79a7c8be304a0cd5ed31f33b506f26eea1462d0
diff --git a/services/audiopolicy/engineconfigurable/src/Engine.cpp b/services/audiopolicy/engineconfigurable/src/Engine.cpp
index 9a61a05..3d74920 100644
--- a/services/audiopolicy/engineconfigurable/src/Engine.cpp
+++ b/services/audiopolicy/engineconfigurable/src/Engine.cpp
@@ -36,6 +36,8 @@
#include <media/TypeConverter.h>
+#include <cinttypes>
+
using std::string;
using std::map;
@@ -166,16 +168,13 @@
status_t Engine::setDeviceConnectionState(const sp<DeviceDescriptor> device,
audio_policy_dev_state_t state)
{
- mPolicyParameterMgr->setDeviceConnectionState(
- device->type(), device->address().c_str(), state);
+ mPolicyParameterMgr->setDeviceConnectionState(device->type(), device->address(), state);
if (audio_is_output_device(device->type())) {
- // FIXME: Use DeviceTypeSet when the interface is ready
return mPolicyParameterMgr->setAvailableOutputDevices(
- deviceTypesToBitMask(getApmObserver()->getAvailableOutputDevices().types()));
+ getApmObserver()->getAvailableOutputDevices().types());
} else if (audio_is_input_device(device->type())) {
- // FIXME: Use DeviceTypeSet when the interface is ready
return mPolicyParameterMgr->setAvailableInputDevices(
- deviceTypesToBitMask(getApmObserver()->getAvailableInputDevices().types()));
+ getApmObserver()->getAvailableInputDevices().types());
}
return EngineBase::setDeviceConnectionState(device, state);
}
@@ -374,17 +373,28 @@
getProductStrategies().at(strategy)->setDeviceAddress(address);
}
-bool Engine::setDeviceTypesForProductStrategy(product_strategy_t strategy, audio_devices_t devices)
+bool Engine::setDeviceTypesForProductStrategy(product_strategy_t strategy, uint64_t devices)
{
if (getProductStrategies().find(strategy) == getProductStrategies().end()) {
- ALOGE("%s: set device %d on invalid strategy %d", __FUNCTION__, devices, strategy);
+ ALOGE("%s: set device %" PRId64 " on invalid strategy %d", __FUNCTION__, devices, strategy);
return false;
}
- // FIXME: stop using deviceTypesFromBitMask when the interface is ready
- getProductStrategies().at(strategy)->setDeviceTypes(deviceTypesFromBitMask(devices));
+ // Here device matches the criterion value, need to rebuitd android device types;
+ DeviceTypeSet types =
+ mPolicyParameterMgr->convertDeviceCriterionValueToDeviceTypes(devices, true /*isOut*/);
+ getProductStrategies().at(strategy)->setDeviceTypes(types);
return true;
}
+bool Engine::setDeviceForInputSource(const audio_source_t &inputSource, uint64_t device)
+{
+ DeviceTypeSet types = mPolicyParameterMgr->convertDeviceCriterionValueToDeviceTypes(
+ device, false /*isOut*/);
+ ALOG_ASSERT(types.size() <= 1, "one input device expected at most");
+ audio_devices_t deviceType = types.empty() ? AUDIO_DEVICE_IN_DEFAULT : *types.begin();
+ return setPropertyForKey<audio_devices_t, audio_source_t>(deviceType, inputSource);
+}
+
template <>
EngineInterface *Engine::queryInterface()
{