Merge "audiopolicy: fix routing of exclusive preferred device" into qt-dev
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 80393ca..af29f87 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1641,7 +1641,14 @@
outputDesc->setClientActive(client, true);
if (client->hasPreferredDevice(true)) {
- devices = getNewOutputDevices(outputDesc, false /*fromCache*/);
+ if (outputDesc->clientsList(true /*activeOnly*/).size() == 1 &&
+ client->isPreferredDeviceForExclusiveUse()) {
+ // Preferred device may be exclusive, use only if no other active clients on this output
+ devices = DeviceVector(
+ mAvailableOutputDevices.getDeviceFromId(client->preferredDeviceId()));
+ } else {
+ devices = getNewOutputDevices(outputDesc, false /*fromCache*/);
+ }
if (devices != outputDesc->devices()) {
checkStrategyRoute(clientStrategy, outputDesc->mIoHandle);
}