audiopolicy: common: add several helper function on DeviceDesc
-Add another DeviceVector constructor to simplify usage
-report tagname as port name
-migrate API from apm
-search/filter helpers
Test: Audio smoke tests.
Test: CTS tests for AudioRecord, AudioTrack and AudioEffect
Change-Id: Ie37a2d9db2e8a15a37743e7129159fa77a4c6b51
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index aa7ffc8..86993d4 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -519,6 +519,19 @@
return mAvailableInputDevices.getDeviceTypesFromHwModule(
mPrimaryOutput->getModuleHandle());
}
+ /**
+ * @brief getFirstDeviceId of the Device Vector
+ * @return if the collection is not empty, it returns the first device Id,
+ * otherwise AUDIO_PORT_HANDLE_NONE
+ */
+ audio_port_handle_t getFirstDeviceId(const DeviceVector &devices) const
+ {
+ return (devices.size() > 0) ? devices.itemAt(0)->getId() : AUDIO_PORT_HANDLE_NONE;
+ }
+ String8 getFirstDeviceAddress(const DeviceVector &devices) const
+ {
+ return (devices.size() > 0) ? devices.itemAt(0)->address() : String8("");
+ }
uint32_t updateCallRouting(audio_devices_t rxDevice, uint32_t delayMs = 0);
sp<AudioPatch> createTelephonyPatch(bool isRx, audio_devices_t device, uint32_t delayMs);