Convert getDevicesForStream to return a DeviceTypeSet
As a pre-requisite for switching from 'int' to
'AudioDeviceDescription' in the framework AIDL interfaces,
get rid of the usage of 'int' as a mask of 'audio_devices_t'
values. This is needed because 'AudioDeviceDescription'
can't be coerced into an int directly, and interpreting
a mask of multiple 'audio_devices_t' values is ambiguous
due to presence of multi-bit device types.
Note that at the Java layer the returned DeviceTypeSet
is still collapsed into a single integer value. This needs
to be addressed separately.
Bug: 188932434
Test: check audio on device
Change-Id: I1bc2a28ac2e1037a38b7be7967349b33845f88de
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 49db0d1..18bc7bd 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -5917,13 +5917,13 @@
return (stream1 == stream2);
}
-audio_devices_t AudioPolicyManager::getDevicesForStream(audio_stream_type_t stream) {
+DeviceTypeSet AudioPolicyManager::getDevicesForStream(audio_stream_type_t stream) {
// By checking the range of stream before calling getStrategy, we avoid
// getOutputDevicesForStream's behavior for invalid streams.
// engine's getOutputDevicesForStream would fallback on its default behavior (most probably
// device for music stream), but we want to return the empty set.
if (stream < AUDIO_STREAM_MIN || stream >= AUDIO_STREAM_PUBLIC_CNT) {
- return AUDIO_DEVICE_NONE;
+ return DeviceTypeSet{};
}
DeviceVector activeDevices;
DeviceVector devices;
@@ -5954,8 +5954,7 @@
devices.merge(mAvailableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER));
devices.remove(speakerSafeDevices);
}
- // FIXME: use DeviceTypeSet when Java layer is ready for it.
- return deviceTypesToBitMask(devices.types());
+ return devices.types();
}
status_t AudioPolicyManager::getDevicesForAttributes(