audio policy: fix configurable engine and dynamic policies
Make sure the Engine is never aware of remote submix devices with non
"0" (legacy) addresses as the Engine does not have to deal with devices
only used by dynamic audio policies.
Bug: 129144725
Test: make
Change-Id: Ifa19c952e22ac18c5d47e731cbfa41f81fe5c32c
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 762a4b1..e5721ee 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -169,8 +169,6 @@
broadcastDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE);
return INVALID_OPERATION;
}
- // Propagate device availability to Engine
- mEngine->setDeviceConnectionState(device, state);
// outputs should never be empty here
ALOG_ASSERT(outputs.size() != 0, "setDeviceConnectionState():"
@@ -200,8 +198,6 @@
// Reset active device codec
device->setEncodedFormat(AUDIO_FORMAT_DEFAULT);
- // Propagate device availability to Engine
- mEngine->setDeviceConnectionState(device, state);
} break;
default:
@@ -209,6 +205,9 @@
return BAD_VALUE;
}
+ // Propagate device availability to Engine
+ setEngineDeviceConnectionState(device, state);
+
// No need to evaluate playback routing when connecting a remote submix
// output device used by a dynamic policy of type recorder as no
// playback use case is affected.
@@ -318,9 +317,6 @@
if (mAvailableInputDevices.add(device) < 0) {
return NO_MEMORY;
}
-
- // Propagate device availability to Engine
- mEngine->setDeviceConnectionState(device, state);
} break;
// handle input device disconnection
@@ -337,9 +333,6 @@
checkInputsForDevice(device, state, inputs);
mAvailableInputDevices.remove(device);
-
- // Propagate device availability to Engine
- mEngine->setDeviceConnectionState(device, state);
} break;
default:
@@ -347,6 +340,9 @@
return BAD_VALUE;
}
+ // Propagate device availability to Engine
+ setEngineDeviceConnectionState(device, state);
+
closeAllInputs();
// As the input device list can impact the output device selection, update
// getDeviceForStrategy() cache
@@ -369,6 +365,17 @@
return BAD_VALUE;
}
+void AudioPolicyManager::setEngineDeviceConnectionState(const sp<DeviceDescriptor> device,
+ audio_policy_dev_state_t state) {
+
+ // the Engine does not have to know about remote submix devices used by dynamic audio policies
+ if (audio_is_remote_submix_device(device->type()) && device->address() != "0") {
+ return;
+ }
+ mEngine->setDeviceConnectionState(device, state);
+}
+
+
audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devices_t device,
const char *device_address)
{
@@ -4385,7 +4392,7 @@
continue;
}
// Device is now validated and can be appended to the available devices of the engine
- mEngine->setDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_AVAILABLE);
+ setEngineDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_AVAILABLE);
i++;
}
};
@@ -4399,7 +4406,7 @@
status = NO_INIT;
}
// If microphones address is empty, set it according to device type
- for (size_t i = 0; i < mAvailableInputDevices.size(); i++) {
+ for (size_t i = 0; i < mAvailableInputDevices.size(); i++) {
if (mAvailableInputDevices[i]->address().isEmpty()) {
if (mAvailableInputDevices[i]->type() == AUDIO_DEVICE_IN_BUILTIN_MIC) {
mAvailableInputDevices[i]->setAddress(String8(AUDIO_BOTTOM_MICROPHONE_ADDRESS));