diff options
| -rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 62569512566c..2243e354ea25 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2111,13 +2111,19 @@ bool AudioFlinger::MixerThread::threadLoop() if (mSuspended) { sleepTime = suspendSleepTimeUs(); } - // sleepTime == 0 means we must write to audio hardware + + // only process effects if we're going to write if (sleepTime == 0) { for (size_t i = 0; i < effectChains.size(); i ++) { effectChains[i]->process_l(); } - // enable changes in effect chain - unlockEffectChains(effectChains); + } + + // enable changes in effect chain + unlockEffectChains(effectChains); + + // sleepTime == 0 means we must write to audio hardware + if (sleepTime == 0) { mLastWriteTime = systemTime(); mInWrite = true; mBytesWritten += mixBufferSize; @@ -2141,8 +2147,6 @@ bool AudioFlinger::MixerThread::threadLoop() } mStandby = false; } else { - // enable changes in effect chain - unlockEffectChains(effectChains); usleep(sleepTime); } @@ -2920,7 +2924,8 @@ bool AudioFlinger::DirectOutputThread::threadLoop() if (mSuspended) { sleepTime = suspendSleepTimeUs(); } - // sleepTime == 0 means we must write to audio hardware + + // only process effects if we're going to write if (sleepTime == 0) { if (mixerStatus == MIXER_TRACKS_READY) { applyVolume(leftVol, rightVol, rampVolume); @@ -2928,8 +2933,13 @@ bool AudioFlinger::DirectOutputThread::threadLoop() for (size_t i = 0; i < effectChains.size(); i ++) { effectChains[i]->process_l(); } - unlockEffectChains(effectChains); + } + // enable changes in effect chain + unlockEffectChains(effectChains); + + // sleepTime == 0 means we must write to audio hardware + if (sleepTime == 0) { mLastWriteTime = systemTime(); mInWrite = true; mBytesWritten += mixBufferSize; @@ -2939,7 +2949,6 @@ bool AudioFlinger::DirectOutputThread::threadLoop() mInWrite = false; mStandby = false; } else { - unlockEffectChains(effectChains); usleep(sleepTime); } @@ -3191,14 +3200,19 @@ bool AudioFlinger::DuplicatingThread::threadLoop() if (mSuspended) { sleepTime = suspendSleepTimeUs(); } - // sleepTime == 0 means we must write to audio hardware + + // only process effects if we're going to write if (sleepTime == 0) { for (size_t i = 0; i < effectChains.size(); i ++) { effectChains[i]->process_l(); } - // enable changes in effect chain - unlockEffectChains(effectChains); + } + + // enable changes in effect chain + unlockEffectChains(effectChains); + // sleepTime == 0 means we must write to audio hardware + if (sleepTime == 0) { standbyTime = systemTime() + mStandbyTimeInNsecs; for (size_t i = 0; i < outputTracks.size(); i++) { outputTracks[i]->write(mMixBuffer, writeFrames); @@ -3206,8 +3220,6 @@ bool AudioFlinger::DuplicatingThread::threadLoop() mStandby = false; mBytesWritten += mixBufferSize; } else { - // enable changes in effect chain - unlockEffectChains(effectChains); usleep(sleepTime); } |