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

Commit 6f6b31da authored by Zhijun He's avatar Zhijun He Committed by Android (Google) Code Review
Browse files

Merge "Camera3: Fix the deadlock during recording pinch zooming" into jb-mr2-dev

parents 6947f125 124ccf4b
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -165,12 +165,21 @@ status_t Camera3OutputStream::returnBufferCheckedLocked(

    int anwReleaseFence = releaseFence->dup();

    /**
     * Release the lock briefly to avoid deadlock with
     * StreamingProcessor::startStream -> Camera3Stream::isConfiguring (this
     * thread will go into StreamingProcessor::onFrameAvailable) during
     * queueBuffer
     */
    sp<ANativeWindow> currentConsumer = mConsumer;
    mLock.unlock();

    /**
     * Return buffer back to ANativeWindow
     */
    if (buffer.status == CAMERA3_BUFFER_STATUS_ERROR) {
        // Cancel buffer
        res = mConsumer->cancelBuffer(mConsumer.get(),
        res = currentConsumer->cancelBuffer(currentConsumer.get(),
                container_of(buffer.buffer, ANativeWindowBuffer, handle),
                anwReleaseFence);
        if (res != OK) {
@@ -178,7 +187,7 @@ status_t Camera3OutputStream::returnBufferCheckedLocked(
                  " %s (%d)", __FUNCTION__, mId, strerror(-res), res);
        }
    } else {
        res = mConsumer->queueBuffer(mConsumer.get(),
        res = currentConsumer->queueBuffer(currentConsumer.get(),
                container_of(buffer.buffer, ANativeWindowBuffer, handle),
                anwReleaseFence);
        if (res != OK) {
@@ -186,7 +195,7 @@ status_t Camera3OutputStream::returnBufferCheckedLocked(
                  "%s (%d)", __FUNCTION__, mId, strerror(-res), res);
        }
    }

    mLock.lock();
    if (res != OK) {
        close(anwReleaseFence);
        return res;
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ class Camera3OutputStream :
    Camera3OutputStream(int id, camera3_stream_type_t type,
            uint32_t width, uint32_t height, int format);

    /**
     * Note that we release the lock briefly in this function
     */
    virtual status_t returnBufferCheckedLocked(
            const camera3_stream_buffer &buffer,
            nsecs_t timestamp,