audio policy: update output delayMs in setPhoneState

- Issue: When call is connected in HDMI while playing music,
  Playback is routed to phone shortly
- Cause: delayMs is not updated correctly, and no delay is
  set when setOutputDevice is called
- Fix: update delayMs with biggest mOutput latency and mute
  STRATEGY_MEDIA on all outputs

Bug: 7268860
Change-Id: I12b75443a29ab8485314bd0cbfe5ee4789be5c29
Signed-off-by: Iliyan Malchev <malchev@google.com>
This commit is contained in:
SathishKumar Mani 2012-10-10 18:58:40 -07:00 committed by Iliyan Malchev
parent aac673172c
commit 772686310a

View file

@ -341,6 +341,22 @@ void AudioPolicyManagerBase::setPhoneState(int state)
setStreamMute(AudioSystem::RING, true, mPrimaryOutput);
}
if (isStateInCall(state)) {
for (size_t i = 0; i < mOutputs.size(); i++) {
AudioOutputDescriptor *desc = mOutputs.valueAt(i);
//take the biggest latency for all outputs
if (delayMs < desc->mLatency*2) {
delayMs = desc->mLatency*2;
}
//mute STRATEGY_MEDIA on all outputs
if (desc->strategyRefCount(STRATEGY_MEDIA) != 0) {
setStrategyMute(STRATEGY_MEDIA, true, mOutputs.keyAt(i));
setStrategyMute(STRATEGY_MEDIA, false, mOutputs.keyAt(i), MUTE_TIME_MS,
getDeviceForStrategy(STRATEGY_MEDIA, true /*fromCache*/));
}
}
}
// change routing is necessary
setOutputDevice(mPrimaryOutput, newDevice, force, delayMs);