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

Commit 8b949276 authored by Eric Laurent's avatar Eric Laurent Committed by Gerrit Code Review
Browse files

Merge "Increase lock scope to protect variables" into main

parents 56629b45 a0de6c6e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -366,14 +366,15 @@ status_t AudioEffect::command(uint32_t cmdCode,
        return mStatus;
    }

    std::unique_lock ul(mLock, std::defer_lock);
    if (cmdCode == EFFECT_CMD_ENABLE || cmdCode == EFFECT_CMD_DISABLE) {
        ul.lock();
        if (mEnabled == (cmdCode == EFFECT_CMD_ENABLE)) {
            return NO_ERROR;
        }
        if (replySize == nullptr || *replySize != sizeof(status_t) || replyData == nullptr) {
            return BAD_VALUE;
        }
        mLock.lock();
    }

    std::vector<uint8_t> data;
@@ -398,7 +399,6 @@ status_t AudioEffect::command(uint32_t cmdCode,
        if (status == NO_ERROR) {
            mEnabled = (cmdCode == EFFECT_CMD_ENABLE);
        }
        mLock.unlock();
    }

    return status;