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

Commit 4c9736fb authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: fix release fence logic

According to spec, HAL will set release_fence to acquire_fence
when error happened (usually during flush call). Camera service
should not refer to the acquireFence anyhow since per spec HAL
needs to set it to -1 if acquireFence has been waited on.

Change-Id: I809355d0c8c71f78f657e37d19221fd1f5bdc90b
parent 0e442128
Loading
Loading
Loading
Loading
+9 −26
Original line number Diff line number Diff line
@@ -157,33 +157,9 @@ status_t Camera3OutputStream::returnBufferCheckedLocked(
    ALOG_ASSERT(output, "Expected output to be true");

    status_t res;
    sp<Fence> releaseFence;

    /**
     * Fence management - calculate Release Fence
     */
    if (buffer.status == CAMERA3_BUFFER_STATUS_ERROR) {
        if (buffer.release_fence != -1) {
            ALOGE("%s: Stream %d: HAL should not set release_fence(%d) when "
                  "there is an error", __FUNCTION__, mId, buffer.release_fence);
            close(buffer.release_fence);
        }

        /**
         * Reassign release fence as the acquire fence in case of error
         */
        releaseFence = new Fence(buffer.acquire_fence);
    } else {
        res = native_window_set_buffers_timestamp(mConsumer.get(), timestamp);
        if (res != OK) {
            ALOGE("%s: Stream %d: Error setting timestamp: %s (%d)",
                  __FUNCTION__, mId, strerror(-res), res);
            return res;
        }

        releaseFence = new Fence(buffer.release_fence);
    }

    // Fence management - always honor release fence from HAL
    sp<Fence> releaseFence = new Fence(buffer.release_fence);
    int anwReleaseFence = releaseFence->dup();

    /**
@@ -217,6 +193,13 @@ status_t Camera3OutputStream::returnBufferCheckedLocked(
            mTraceFirstBuffer = false;
        }

        res = native_window_set_buffers_timestamp(mConsumer.get(), timestamp);
        if (res != OK) {
            ALOGE("%s: Stream %d: Error setting timestamp: %s (%d)",
                  __FUNCTION__, mId, strerror(-res), res);
            return res;
        }

        res = currentConsumer->queueBuffer(currentConsumer.get(),
                container_of(buffer.buffer, ANativeWindowBuffer, handle),
                anwReleaseFence);