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

Commit 69a37489 authored by Zhijun He's avatar Zhijun He
Browse files

Camera3: Fix flush call deadlock

Flush shouldn't call waitUntilDrained directly, as they are all API calls
with mLock and mInterfaceLock held. Move the waitUntilDrained implementation
into waitUntilDrainedLocked to solve this issue.

Change-Id: Id7d931091d5c11e12204790841097433515446db
parent 2f5d0b32
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -997,6 +997,10 @@ status_t Camera3Device::waitUntilDrained() {
    Mutex::Autolock il(mInterfaceLock);
    Mutex::Autolock il(mInterfaceLock);
    Mutex::Autolock l(mLock);
    Mutex::Autolock l(mLock);


    return waitUntilDrainedLocked();
}

status_t Camera3Device::waitUntilDrainedLocked() {
    switch (mStatus) {
    switch (mStatus) {
        case STATUS_UNINITIALIZED:
        case STATUS_UNINITIALIZED:
        case STATUS_UNCONFIGURED:
        case STATUS_UNCONFIGURED:
@@ -1207,7 +1211,7 @@ status_t Camera3Device::flush() {
    if (mHal3Device->common.version >= CAMERA_DEVICE_API_VERSION_3_1) {
    if (mHal3Device->common.version >= CAMERA_DEVICE_API_VERSION_3_1) {
        res = mHal3Device->ops->flush(mHal3Device);
        res = mHal3Device->ops->flush(mHal3Device);
    } else {
    } else {
        res = waitUntilDrained();
        res = waitUntilDrainedLocked();
    }
    }


    return res;
    return res;
+7 −0
Original line number Original line Diff line number Diff line
@@ -245,6 +245,13 @@ class Camera3Device :
     */
     */
    status_t waitUntilStateThenRelock(bool active, nsecs_t timeout);
    status_t waitUntilStateThenRelock(bool active, nsecs_t timeout);


    /**
     * Implementation of waitUntilDrained. On success, will transition to IDLE state.
     *
     * Need to be called with mLock and mInterfaceLock held.
     */
    status_t waitUntilDrainedLocked();

    /**
    /**
     * Do common work for setting up a streaming or single capture request.
     * Do common work for setting up a streaming or single capture request.
     * On success, will transition to ACTIVE if in IDLE.
     * On success, will transition to ACTIVE if in IDLE.