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

Commit acff0376 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add mInterfaceLock back to Camera3Device methods called by RequestThread." am: e4f1dbca

Change-Id: Ie5a94dd945642b9c41230c686c640faef6e9ff84
parents 77fff26a e4f1dbca
Loading
Loading
Loading
Loading
+70 −71
Original line number Original line Diff line number Diff line
@@ -339,12 +339,12 @@ status_t Camera3Device::disconnect() {


status_t Camera3Device::disconnectImpl() {
status_t Camera3Device::disconnectImpl() {
    ATRACE_CALL();
    ATRACE_CALL();
    Mutex::Autolock il(mInterfaceLock);

    ALOGI("%s: E", __FUNCTION__);
    ALOGI("%s: E", __FUNCTION__);


    status_t res = OK;
    status_t res = OK;
    std::vector<wp<Camera3StreamInterface>> streams;
    std::vector<wp<Camera3StreamInterface>> streams;
    {
        Mutex::Autolock il(mInterfaceLock);
        nsecs_t maxExpectedDuration = getExpectedInFlightDuration();
        nsecs_t maxExpectedDuration = getExpectedInFlightDuration();
        {
        {
            Mutex::Autolock l(mLock);
            Mutex::Autolock l(mLock);
@@ -386,16 +386,19 @@ status_t Camera3Device::disconnectImpl() {
                streams.push_back(mInputStream);
                streams.push_back(mInputStream);
            }
            }
        }
        }

    }
    // Joining done without holding mLock, otherwise deadlocks may ensue
    // Joining done without holding mLock and mInterfaceLock, otherwise deadlocks may ensue
    // as the threads try to access parent state
    // as the threads try to access parent state (b/143513518)
    if (mRequestThread != NULL && mStatus != STATUS_ERROR) {
    if (mRequestThread != NULL && mStatus != STATUS_ERROR) {
        // HAL may be in a bad state, so waiting for request thread
        // HAL may be in a bad state, so waiting for request thread
        // (which may be stuck in the HAL processCaptureRequest call)
        // (which may be stuck in the HAL processCaptureRequest call)
        // could be dangerous.
        // could be dangerous.
        // give up mInterfaceLock here and then lock it again. Could this lead
        // to other deadlocks
        mRequestThread->join();
        mRequestThread->join();
    }
    }

    {
        Mutex::Autolock il(mInterfaceLock);
        if (mStatusTracker != NULL) {
        if (mStatusTracker != NULL) {
            mStatusTracker->join();
            mStatusTracker->join();
        }
        }
@@ -432,7 +435,7 @@ status_t Camera3Device::disconnectImpl() {
                        __FUNCTION__, stream->getId(), stream->getStrongCount() - 1);
                        __FUNCTION__, stream->getId(), stream->getStrongCount() - 1);
            }
            }
        }
        }

    }
    ALOGI("%s: X", __FUNCTION__);
    ALOGI("%s: X", __FUNCTION__);
    return res;
    return res;
}
}
@@ -2165,9 +2168,7 @@ void Camera3Device::internalUpdateStatusLocked(Status status) {
}
}


void Camera3Device::pauseStateNotify(bool enable) {
void Camera3Device::pauseStateNotify(bool enable) {
    // We must not hold mInterfaceLock here since this function is called from
    Mutex::Autolock il(mInterfaceLock);
    // RequestThread::threadLoop and holding mInterfaceLock could lead to
    // deadlocks (http://b/143513518)
    Mutex::Autolock l(mLock);
    Mutex::Autolock l(mLock);


    mPauseStateNotify = enable;
    mPauseStateNotify = enable;
@@ -2744,9 +2745,7 @@ bool Camera3Device::reconfigureCamera(const CameraMetadata& sessionParams) {
    ATRACE_CALL();
    ATRACE_CALL();
    bool ret = false;
    bool ret = false;


    // We must not hold mInterfaceLock here since this function is called from
    Mutex::Autolock il(mInterfaceLock);
    // RequestThread::threadLoop and holding mInterfaceLock could lead to
    // deadlocks (http://b/143513518)
    nsecs_t maxExpectedDuration = getExpectedInFlightDuration();
    nsecs_t maxExpectedDuration = getExpectedInFlightDuration();


    Mutex::Autolock l(mLock);
    Mutex::Autolock l(mLock);
+0 −1
Original line number Original line Diff line number Diff line
@@ -244,7 +244,6 @@ class Camera3Device :


    // A lock to enforce serialization on the input/configure side
    // A lock to enforce serialization on the input/configure side
    // of the public interface.
    // of the public interface.
    // Only locked by public methods inherited from CameraDeviceBase.
    // Not locked by methods guarded by mOutputLock, since they may act
    // Not locked by methods guarded by mOutputLock, since they may act
    // concurrently to the input/configure side of the interface.
    // concurrently to the input/configure side of the interface.
    // Must be locked before mLock if both will be locked by a method
    // Must be locked before mLock if both will be locked by a method