audioflinger: keep wakelock during offload playback

Add a system property ro.audio.offload_wakelock to select
if a wakelock should be kept during offload playback while waiting for
write completion callback.
The default is yes, keep the wakelock.

On some platforms, the cost of entering or exiting suspend is so high
that is it better to not release a wakelock at all rather than releasing
it periodically.

Bug: 26208297
Change-Id: Ib41c7e4ed9c8c0c063363eb9fe99a2ecc81b521b
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 {