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

Commit bb6ac182 authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android (Google) Code Review
Browse files

Merge "Camera: Do not signal AutoConditionLock if acquisition times out" into nyc-dev

parents 89b3068f 34713c04
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -24,14 +24,16 @@ WaitableMutexWrapper::~WaitableMutexWrapper() {}

// Locks manager-owned mutex
AutoConditionLock::AutoConditionLock(const std::shared_ptr<WaitableMutexWrapper>& manager) :
        mManager{manager}, mAutoLock{manager->mMutex} {}
        mManager{manager}, mAutoLock{manager->mMutex}, mAcquired(false) {}

// Unlocks manager-owned mutex
AutoConditionLock::~AutoConditionLock() {
    // Unset the condition and wake everyone up before releasing lock
    if (mAcquired) {
        mManager->mState = false;
        mManager->mCondition.broadcast();
    }
}

std::unique_ptr<AutoConditionLock> AutoConditionLock::waitAndAcquire(
        const std::shared_ptr<WaitableMutexWrapper>& manager, nsecs_t waitTime) {
@@ -59,6 +61,7 @@ std::unique_ptr<AutoConditionLock> AutoConditionLock::waitAndAcquire(

    // Set the condition and return
    manager->mState = true;
    scopedLock->mAcquired = true;
    return scopedLock;
}

@@ -84,6 +87,7 @@ std::unique_ptr<AutoConditionLock> AutoConditionLock::waitAndAcquire(

    // Set the condition and return
    manager->mState = true;
    scopedLock->mAcquired = true;
    return scopedLock;
}

+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ private:

    std::shared_ptr<WaitableMutexWrapper> mManager;
    Mutex::Autolock mAutoLock;
    bool mAcquired;
};

}; // namespace android