From fe472e292ab50c121ff93dffa3b54c96feedcfef Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Tue, 16 Dec 2014 14:23:13 -0800 Subject: Fix routing not happening after change in output device list If an output stream is active while rerouting rules are installed and recording starts, the list of outputs is not updated and therefore the stream is not rerouted to the new virtual device. The fix consists in also taking into account all the policy-related outputs when evaluating the before and after list of outputs following a connection state event. Bug 18736417 Change-Id: I6697976b3f89e2c0995e888e9046a2273361bb97 --- services/audiopolicy/AudioPolicyManager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'services/audiopolicy') diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index a71aa53..51854c3 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -4055,6 +4055,24 @@ void AudioPolicyManager::checkOutputForStrategy(routing_strategy strategy) SortedVector srcOutputs = getOutputsForDevice(oldDevice, mPreviousOutputs); SortedVector dstOutputs = getOutputsForDevice(newDevice, mOutputs); + // also take into account external policy-related changes: add all outputs which are + // associated with policies in the "before" and "after" output vectors + ALOGVV("checkOutputForStrategy(): policy related outputs"); + for (size_t i = 0 ; i < mPreviousOutputs.size() ; i++) { + const sp desc = mPreviousOutputs.valueAt(i); + if (desc != 0 && desc->mPolicyMix != NULL) { + srcOutputs.add(desc->mIoHandle); + ALOGVV(" previous outputs: adding %d", desc->mIoHandle); + } + } + for (size_t i = 0 ; i < mOutputs.size() ; i++) { + const sp desc = mOutputs.valueAt(i); + if (desc != 0 && desc->mPolicyMix != NULL) { + dstOutputs.add(desc->mIoHandle); + ALOGVV(" new outputs: adding %d", desc->mIoHandle); + } + } + if (!vectorsEqual(srcOutputs,dstOutputs)) { ALOGV("checkOutputForStrategy() strategy %d, moving from output %d to output %d", strategy, srcOutputs[0], dstOutputs[0]); -- cgit v1.1