Merge "audioflinger: keep wakelock during offload playback" into nyc-dev
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 9b57960..b82682d 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2928,11 +2928,7 @@
break;
}
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)) {
+ if (!keepWakeLock()) {
releaseWakeLock_l();
released = true;
}
@@ -5169,10 +5165,11 @@
AudioStreamOut* output, audio_io_handle_t id, uint32_t device, bool systemReady,
uint32_t bitRate)
: DirectOutputThread(audioFlinger, output, id, device, OFFLOAD, systemReady, bitRate),
- mPausedBytesRemaining(0)
+ mPausedWriteLength(0), mPausedBytesRemaining(0), mKeepWakeLock(true)
{
//FIXME: mStandby should be set to true by ThreadBase constructor
mStandby = true;
+ mKeepWakeLock = property_get_bool("ro.audio.offload_wakelock", true /* default_value */);
}
void AudioFlinger::OffloadThread::threadLoop_exit()
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 761fc71..cf896e0 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -527,6 +527,8 @@
// ThreadBase virtuals
virtual void preExit();
+ virtual bool keepWakeLock() const { return true; }
+
public:
virtual status_t initCheck() const { return (mOutput == NULL) ? NO_INIT : NO_ERROR; }
@@ -996,9 +998,12 @@
virtual bool waitingAsyncCallback();
virtual bool waitingAsyncCallback_l();
+ virtual bool keepWakeLock() const { return mKeepWakeLock; }
+
private:
size_t mPausedWriteLength; // length in bytes of write interrupted by pause
size_t mPausedBytesRemaining; // bytes still waiting in mixbuffer after resume
+ bool mKeepWakeLock; // keep wake lock while waiting for write callback
};
class AsyncCallbackThread : public Thread {