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

Commit e70521b7 authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Gerrit Code Review
Browse files

Merge "cameraserver: clear all requests and signal mRequestSignal from...

Merge "cameraserver: clear all requests and signal mRequestSignal from RequestThread during disconnect()."
parents 1e2bd24f a93f346e
Loading
Loading
Loading
Loading
+26 −17
Original line number Original line Diff line number Diff line
@@ -250,9 +250,9 @@ status_t Camera3Device::disconnectImpl() {
            Mutex::Autolock l(mLock);
            Mutex::Autolock l(mLock);
            if (mStatus == STATUS_UNINITIALIZED) return res;
            if (mStatus == STATUS_UNINITIALIZED) return res;


            if (mStatus == STATUS_ACTIVE ||
            if (mRequestThread != NULL) {
                    (mStatus == STATUS_ERROR && mRequestThread != NULL)) {
                if (mStatus == STATUS_ACTIVE || mStatus == STATUS_ERROR) {
                res = mRequestThread->clearRepeatingRequests();
                    res = mRequestThread->clear();
                    if (res != OK) {
                    if (res != OK) {
                        SET_ERR_L("Can't stop streaming");
                        SET_ERR_L("Can't stop streaming");
                        // Continue to close device even in case of error
                        // Continue to close device even in case of error
@@ -265,6 +265,14 @@ 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) {
            if (mStatus == STATUS_ERROR) {
                CLOGE("Shutting down in an error state");
                CLOGE("Shutting down in an error state");
@@ -3047,7 +3055,8 @@ status_t Camera3Device::RequestThread::clearRepeatingRequests(/*out*/int64_t *la


}
}


status_t Camera3Device::RequestThread::clearRepeatingRequestsLocked(/*out*/int64_t *lastFrameNumber) {
status_t Camera3Device::RequestThread::clearRepeatingRequestsLocked(
        /*out*/int64_t *lastFrameNumber) {
    std::vector<int32_t> streamIds;
    std::vector<int32_t> streamIds;
    for (const auto& request : mRepeatingRequests) {
    for (const auto& request : mRepeatingRequests) {
        for (const auto& stream : request->mOutputStreams) {
        for (const auto& stream : request->mOutputStreams) {
@@ -3072,8 +3081,6 @@ status_t Camera3Device::RequestThread::clear(
    Mutex::Autolock l(mRequestLock);
    Mutex::Autolock l(mRequestLock);
    ALOGV("RequestThread::%s:", __FUNCTION__);
    ALOGV("RequestThread::%s:", __FUNCTION__);


    mRepeatingRequests.clear();

    // Send errors for all requests pending in the request queue, including
    // Send errors for all requests pending in the request queue, including
    // pending repeating requests
    // pending repeating requests
    sp<NotificationListener> listener = mListener.promote();
    sp<NotificationListener> listener = mListener.promote();
@@ -3111,10 +3118,7 @@ status_t Camera3Device::RequestThread::clear(


    Mutex::Autolock al(mTriggerMutex);
    Mutex::Autolock al(mTriggerMutex);
    mTriggerMap.clear();
    mTriggerMap.clear();
    if (lastFrameNumber != NULL) {
    clearRepeatingRequestsLocked(lastFrameNumber);
        *lastFrameNumber = mRepeatingLastFrameNumber;
    }
    mRepeatingLastFrameNumber = hardware::camera2::ICameraDeviceUser::NO_IN_FLIGHT_REPEATING_FRAMES;
    mRequestClearing = true;
    mRequestClearing = true;
    mRequestSignal.signal();
    mRequestSignal.signal();
    return OK;
    return OK;
@@ -4209,6 +4213,11 @@ void Camera3Device::RequestThread::waitForNextRequestBatch() {
    return;
    return;
}
}


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

sp<Camera3Device::CaptureRequest>
sp<Camera3Device::CaptureRequest>
        Camera3Device::RequestThread::waitForNextRequestLocked() {
        Camera3Device::RequestThread::waitForNextRequestLocked() {
    status_t res;
    status_t res;
+3 −0
Original line number Original line Diff line number Diff line
@@ -856,6 +856,9 @@ class Camera3Device :
         */
         */
        void     setPaused(bool paused);
        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'
         * Wait until thread processes the capture request with settings'
         * android.request.id == requestId.
         * android.request.id == requestId.