From 3f54b2b7dcdfec8870565588b5e63e93dc5b363d Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Thu, 26 Nov 2015 05:31:01 -0800 Subject: audioflinger: Adjust throttle interval when effects in use * Loud clicks/pops are heard when playing to a USB device with AudioFX enabled. Particularly frequent when the USB device is capable of high-resolution output. * Adjust the throttling period when effects are enabled to prevent this. Change-Id: I3db220d13c37f4ff5b835c14831fbe6f5a5b062c --- services/audioflinger/Threads.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'services/audioflinger') diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index d70e457..4cb88c2 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2990,8 +2990,9 @@ bool AudioFlinger::PlaybackThread::threadLoop() // the app won't fill fast enough to handle the sudden draw). const int32_t deltaMs = delta / 1000000; - const int32_t throttleMs = mHalfBufferMs - deltaMs; - if ((signed)mHalfBufferMs >= throttleMs && throttleMs > 0) { + const int32_t halfBufferMs = mHalfBufferMs / (mEffectBufferValid ? 4 : 1); + const int32_t throttleMs = halfBufferMs - deltaMs; + if ((signed)halfBufferMs >= throttleMs && throttleMs > 0) { usleep(throttleMs * 1000); // notify of throttle start on verbose log ALOGV_IF(mThreadThrottleEndMs == mThreadThrottleTimeMs, -- cgit v1.1