Skip to content

Commit 7eeaf3f

Browse files
Eric LaurentAndroid (Google) Code Review
authored andcommitted
Merge "AudioFlinger: refine mixer sleep time logic" into ics-mr1
2 parents 41773d4 + 0609231 commit 7eeaf3f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,11 +1973,14 @@ bool AudioFlinger::MixerThread::threadLoop()
19731973
if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
19741974
// mix buffers...
19751975
mAudioMixer->process();
1976-
sleepTime = 0;
1977-
// increase sleep time progressively when application underrun condition clears
1978-
if (sleepTimeShift > 0) {
1976+
// increase sleep time progressively when application underrun condition clears.
1977+
// Only increase sleep time if the mixer is ready for two consecutive times to avoid
1978+
// that a steady state of alternating ready/not ready conditions keeps the sleep time
1979+
// such that we would underrun the audio HAL.
1980+
if ((sleepTime == 0) && (sleepTimeShift > 0)) {
19791981
sleepTimeShift--;
19801982
}
1983+
sleepTime = 0;
19811984
standbyTime = systemTime() + kStandbyTimeInNsecs;
19821985
//TODO: delay standby when effects have a tail
19831986
} else {

0 commit comments

Comments
 (0)