Fix connection of OUT_REMOTE_SUBMIX device on APM startInput
Fix a regression in AudioPolicyManager::startInput() where
the OUT_REMOTE_SUBMIX audio device was never made available
due to the test on the input descriptor, which was already
active by the time it is tested, as the activity on the
session has already been updated.
Add methods to AudioInputDescriptor and AudioSessionCollection
to query the number of active sessions. Use the new method
to optimize AudioSessionCollection::hasActiveSession()
Bug 26798796
Change-Id: I2de4e47970505e64c4c78a148a80a9f0ec19e821
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index d1d5df6..ad2ad69 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1649,7 +1649,7 @@
setInputDevice(input, getNewInputDevice(inputDesc), true /* force */);
- if (!inputDesc->isActive()) {
+ if (inputDesc->getAudioSessionCount(true/*activeOnly*/) == 1) {
// if input maps to a dynamic policy with an activity listener, notify of state change
if ((inputDesc->mPolicyMix != NULL)
&& ((inputDesc->mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) {