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

Commit dc13880f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "camera: make waiting for state more accurate" into tm-dev am:...

Merge "camera: make waiting for state more accurate" into tm-dev am: 1b80a837 am: bc8d6cde am: 5da42c4b

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



Change-Id: I561ccdfdd0b36990bd14713b48c6057bba064231
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4c885ad9 5da42c4b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1559,13 +1559,22 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout) {
    }

    bool stateSeen = false;
    nsecs_t startTime = systemTime();
    do {
        if (active == (mStatus == STATUS_ACTIVE)) {
            // Desired state is current
            break;
        }

        res = mStatusChanged.waitRelative(mLock, timeout);
        nsecs_t timeElapsed = systemTime() - startTime;
        nsecs_t timeToWait = timeout - timeElapsed;
        if (timeToWait <= 0) {
            // Thread woke up spuriously but has timed out since.
            // Force out of loop with TIMED_OUT result.
            res = TIMED_OUT;
            break;
        }
        res = mStatusChanged.waitRelative(mLock, timeToWait);
        if (res != OK) break;

        // This is impossible, but if not, could result in subtle deadlocks and invalid state