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

Commit 5da42c4b 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: 1b80a837 am: bc8d6cde

parents 9180a32b bc8d6cde
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -1559,13 +1559,22 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout) {
    }
    }


    bool stateSeen = false;
    bool stateSeen = false;
    nsecs_t startTime = systemTime();
    do {
    do {
        if (active == (mStatus == STATUS_ACTIVE)) {
        if (active == (mStatus == STATUS_ACTIVE)) {
            // Desired state is current
            // Desired state is current
            break;
            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;
        if (res != OK) break;


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