am a7c17deb: audio policy: notification delay - DO NOT MERGE

* commit 'a7c17deb32fe28230b77b0dff17bb113088a5c16':
  audio policy: notification delay - DO NOT MERGE
This commit is contained in:
Eric Laurent 2012-11-08 14:35:56 -08:00 committed by Android Git Automerger
commit 85f8faa657
2 changed files with 17 additions and 3 deletions

View file

@ -348,7 +348,7 @@ void AudioPolicyManagerBase::setPhoneState(int state)
for (size_t i = 0; i < mOutputs.size(); i++) { for (size_t i = 0; i < mOutputs.size(); i++) {
AudioOutputDescriptor *desc = mOutputs.valueAt(i); AudioOutputDescriptor *desc = mOutputs.valueAt(i);
//take the biggest latency for all outputs //take the biggest latency for all outputs
if (delayMs < desc->mLatency*2) { if (delayMs < (int)desc->mLatency*2) {
delayMs = desc->mLatency*2; delayMs = desc->mLatency*2;
} }
//mute STRATEGY_MEDIA on all outputs //mute STRATEGY_MEDIA on all outputs
@ -702,8 +702,9 @@ status_t AudioPolicyManagerBase::startOutput(audio_io_handle_t output,
} }
// wait for audio on other active outputs to be presented when starting // wait for audio on other active outputs to be presented when starting
// a notification so that audio focus effect can propagate. // a notification so that audio focus effect can propagate.
if (shouldWait && (desc->refCount() != 0) && (waitMs < desc->latency())) { uint32_t latency = desc->latency();
waitMs = desc->latency(); if (shouldWait && desc->isActive(latency * 2) && (waitMs < latency)) {
waitMs = latency;
} }
} }
} }
@ -3065,6 +3066,18 @@ audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::supportedDevices(
} }
} }
bool AudioPolicyManagerBase::AudioOutputDescriptor::isActive(uint32_t inPastMs) const
{
nsecs_t sysTime = systemTime();
for (int i = 0; i < AudioSystem::NUM_STREAM_TYPES; i++) {
if (mRefCount[i] != 0 ||
ns2ms(sysTime - mStopTime[i]) < inPastMs) {
return true;
}
}
return false;
}
status_t AudioPolicyManagerBase::AudioOutputDescriptor::dump(int fd) status_t AudioPolicyManagerBase::AudioOutputDescriptor::dump(int fd)
{ {
const size_t SIZE = 256; const size_t SIZE = 256;

View file

@ -250,6 +250,7 @@ protected:
audio_devices_t supportedDevices(); audio_devices_t supportedDevices();
uint32_t latency(); uint32_t latency();
bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc); bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc);
bool isActive(uint32_t inPastMs) const;
audio_io_handle_t mId; // output handle audio_io_handle_t mId; // output handle
uint32_t mSamplingRate; // uint32_t mSamplingRate; //