APM: call getAudioPort to retrieve capabilities for input device port.
Bug: 277785275
Test: atest audiopolicy_tests
Change-Id: Ie98a66cd79c4ae4bb35a306bad04369f32cffc9b
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 7b6b0fe..9fc4b1e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -6082,6 +6082,14 @@
}
if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
+ // first call getAudioPort to get the supported attributes from the HAL
+ struct audio_port_v7 port = {};
+ device->toAudioPort(&port);
+ status_t status = mpClientInterface->getAudioPort(&port);
+ if (status == NO_ERROR) {
+ device->importAudioPort(port);
+ }
+
// look for input profiles that can be routed to this device
SortedVector< sp<IOProfile> > profiles;
for (const auto& hwModule : mHwModules) {
@@ -6133,11 +6141,7 @@
desc = new AudioInputDescriptor(profile, mpClientInterface);
audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
- status_t status = desc->open(nullptr,
- device,
- AUDIO_SOURCE_MIC,
- AUDIO_INPUT_FLAG_NONE,
- &input);
+ status = desc->open(nullptr, device, AUDIO_SOURCE_MIC, AUDIO_INPUT_FLAG_NONE, &input);
if (status == NO_ERROR) {
const String8& address = String8(device->address().c_str());