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

Commit c526e1ef authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audioflinger: keep wakelock during offload playback" into nyc-dev

parents 1e47cb09 64667977
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -2928,11 +2928,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;
                }
@@ -5169,10 +5165,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 {