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

Commit b433c072 authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Automerger Merge Worker
Browse files

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

Merge "cameraserver: clear all requests and signal mRequestSignal from RequestThread during disconnect()." am: e70521b7 am: 40b25026

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



Change-Id: I094662c7682ce419541b1dcf4936dff7b84c3e6d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2421fcff 40b25026
Loading
Loading
Loading
Loading
+26 −17
Original line number Original line Diff line number Diff line
@@ -255,9 +255,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
@@ -270,6 +270,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");
@@ -3052,7 +3060,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) {
@@ -3077,8 +3086,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();
@@ -3116,10 +3123,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;
@@ -4231,6 +4235,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
@@ -861,6 +861,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.