Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64667977 authored by Eric Laurent's avatar Eric Laurent
Browse files

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
parent 029aaa68
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -2924,11 +2924,7 @@ bool AudioFlinger::PlaybackThread::threadLoop()
                    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;
                }
@@ -5165,10 +5161,11 @@ AudioFlinger::OffloadThread::OffloadThread(const sp<AudioFlinger>& audioFlinger,
        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()
+5 −0
Original line number Diff line number Diff line
@@ -527,6 +527,8 @@ protected:
    // 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 @@ protected:
    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 {