Loading services/audioflinger/Threads.cpp +25 −10 Original line number Diff line number Diff line Loading @@ -4169,6 +4169,20 @@ void AudioFlinger::MixerThread::threadLoop_sleepTime() // buffer size, then write 0s to the output if (mSleepTimeUs == 0) { if (mMixerStatus == MIXER_TRACKS_ENABLED) { if (mPipeSink.get() != nullptr && mPipeSink == mNormalSink) { // Using the Monopipe availableToWrite, we estimate the // sleep time to retry for more data (before we underrun). MonoPipe *monoPipe = static_cast<MonoPipe *>(mPipeSink.get()); const ssize_t availableToWrite = mPipeSink->availableToWrite(); const size_t pipeFrames = monoPipe->maxFrames(); const size_t framesLeft = pipeFrames - max(availableToWrite, 0); // HAL_framecount <= framesDelay ~ framesLeft / 2 <= Normal_Mixer_framecount const size_t framesDelay = std::min( mNormalFrameCount, max(framesLeft / 2, mFrameCount)); ALOGV("pipeFrames:%zu framesLeft:%zu framesDelay:%zu", pipeFrames, framesLeft, framesDelay); mSleepTimeUs = framesDelay * MICROS_PER_SECOND / mSampleRate; } else { mSleepTimeUs = mActiveSleepTimeUs >> sleepTimeShift; if (mSleepTimeUs < kMinThreadSleepTimeUs) { mSleepTimeUs = kMinThreadSleepTimeUs; Loading @@ -4180,6 +4194,7 @@ void AudioFlinger::MixerThread::threadLoop_sleepTime() if (sleepTimeShift < kMaxThreadSleepTimeShift) { sleepTimeShift++; } } } else { mSleepTimeUs = mIdleSleepTimeUs; } Loading Loading
services/audioflinger/Threads.cpp +25 −10 Original line number Diff line number Diff line Loading @@ -4169,6 +4169,20 @@ void AudioFlinger::MixerThread::threadLoop_sleepTime() // buffer size, then write 0s to the output if (mSleepTimeUs == 0) { if (mMixerStatus == MIXER_TRACKS_ENABLED) { if (mPipeSink.get() != nullptr && mPipeSink == mNormalSink) { // Using the Monopipe availableToWrite, we estimate the // sleep time to retry for more data (before we underrun). MonoPipe *monoPipe = static_cast<MonoPipe *>(mPipeSink.get()); const ssize_t availableToWrite = mPipeSink->availableToWrite(); const size_t pipeFrames = monoPipe->maxFrames(); const size_t framesLeft = pipeFrames - max(availableToWrite, 0); // HAL_framecount <= framesDelay ~ framesLeft / 2 <= Normal_Mixer_framecount const size_t framesDelay = std::min( mNormalFrameCount, max(framesLeft / 2, mFrameCount)); ALOGV("pipeFrames:%zu framesLeft:%zu framesDelay:%zu", pipeFrames, framesLeft, framesDelay); mSleepTimeUs = framesDelay * MICROS_PER_SECOND / mSampleRate; } else { mSleepTimeUs = mActiveSleepTimeUs >> sleepTimeShift; if (mSleepTimeUs < kMinThreadSleepTimeUs) { mSleepTimeUs = kMinThreadSleepTimeUs; Loading @@ -4180,6 +4194,7 @@ void AudioFlinger::MixerThread::threadLoop_sleepTime() if (sleepTimeShift < kMaxThreadSleepTimeShift) { sleepTimeShift++; } } } else { mSleepTimeUs = mIdleSleepTimeUs; } Loading