DO NOT MERGE audioflinger: dont release wakelock during offload drain sequence
workaround to avoid lost offload audio buffers during a compress_drain
when a wakelock is not held.
reference internal commit# 078538cfc6c4682889ed52de460d29c0d15bb9eb
Change-Id: I91fe76f985dfb619610f92f946022184564598cb
Signed-off-by: Sridhar Vashist <svashist@motorola.com>
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 9fccda1..98bdbd9 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2467,13 +2467,23 @@
if (exitPending()) {
break;
}
- releaseWakeLock_l();
+ bool released = false;
+ // The following works around a bug in the offload driver. Ideally we would release
+ // the wake lock every time, but that causes the last offload buffer(s) to be
+ // dropped while the device is on battery, so we need to hold a wake lock during
+ // the drain phase.
+ if (mBytesRemaining && !(mDrainSequence & 1)) {
+ releaseWakeLock_l();
+ released = true;
+ }
mWakeLockUids.clear();
mActiveTracksGeneration++;
ALOGV("wait async completion");
mWaitWorkCV.wait(mLock);
ALOGV("async completion/wake");
- acquireWakeLock_l();
+ if (released) {
+ acquireWakeLock_l();
+ }
standbyTime = systemTime() + standbyDelay;
sleepTime = 0;