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

Commit 20d5b7fa authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Sync request thread exit with request clear flag

'mRequestClearing' will be set before the request thread is
able to exit. Depending on timing, the request thread can clear
the flag and wait for the request signal one extra
iteration before it is able to quit.
Avoid the extra wait by requesting exit and enabling the request
clear flag synchronously.

Bug: 297497171
Test: Camera CTS
Change-Id: I7856e633f897e245ca2df7155c6b18c1e6efd81f
parent 0cece702
Loading
Loading
Loading
Loading
+6 −14
Original line number Diff line number Diff line
@@ -295,13 +295,6 @@ status_t Camera3Device::disconnectImpl() {
                    }
                }
            }
            // Signal to request thread that we're not expecting any
            // more requests. This will be true since once we're in
            // disconnect and we've cleared off the request queue, the
            // request thread can't receive any new requests through
            // binder calls - since disconnect holds
            // mBinderSerialization lock.
            mRequestThread->setRequestClearing();
        }

        if (mStatus == STATUS_ERROR) {
@@ -3299,8 +3292,12 @@ status_t Camera3Device::RequestThread::waitUntilRequestProcessed(
}

void Camera3Device::RequestThread::requestExit() {
    {
        Mutex::Autolock l(mRequestLock);
        mRequestClearing = true;
        // Call parent to set up shutdown
        Thread::requestExit();
    }
    // The exit from any possible waits
    mDoPauseSignal.signal();
    mRequestSignal.signal();
@@ -4432,11 +4429,6 @@ void Camera3Device::RequestThread::waitForNextRequestBatch() {
    return;
}

void Camera3Device::RequestThread::setRequestClearing() {
    Mutex::Autolock l(mRequestLock);
    mRequestClearing = true;
}

sp<Camera3Device::CaptureRequest>
        Camera3Device::RequestThread::waitForNextRequestLocked() {
    status_t res;
+0 −3
Original line number Diff line number Diff line
@@ -932,9 +932,6 @@ class Camera3Device :
         */
        void     setPaused(bool paused);

        // set mRequestClearing - no new requests are expected to be queued to RequestThread
        void setRequestClearing();

        /**
         * Wait until thread processes the capture request with settings'
         * android.request.id == requestId.