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

Commit 301002df authored by Ytai Ben-tsvi's avatar Ytai Ben-tsvi Committed by Automerger Merge Worker
Browse files

Merge "Fix race condition resulting in unbalanced wakelock calls" into tm-dev...

Merge "Fix race condition resulting in unbalanced wakelock calls" into tm-dev am: 4d034ec4 am: 6c950c1e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/17967938



Change-Id: I2108f19509bcd614755feadef9b68648a0b70f6c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9d42b528 6c950c1e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1938,12 +1938,16 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
    while (!exitPending())
    {
        sp<AudioPolicyService> svc;
        int numTimesBecameEmpty = 0;
        while (!mAudioCommands.isEmpty() && !exitPending()) {
            nsecs_t curTime = systemTime();
            // commands are sorted by increasing time stamp: execute them from index 0 and up
            if (mAudioCommands[0]->mTime <= curTime) {
                sp<AudioCommand> command = mAudioCommands[0];
                mAudioCommands.removeAt(0);
                if (mAudioCommands.isEmpty()) {
                  ++numTimesBecameEmpty;
                }
                mLastCommand = command;

                switch (command->mCommand) {
@@ -2180,8 +2184,9 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
            }
        }

        // release delayed commands wake lock if the queue is empty
        if (mAudioCommands.isEmpty()) {
        // release delayed commands wake lock as many times as we made the  queue is
        // empty during popping.
        while (numTimesBecameEmpty--) {
            release_wake_lock(mName.string());
        }