From patchwork Mon Mar 29 00:27:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11753 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A583CC32ED for ; Mon, 29 Mar 2021 00:27:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 615FB68784; Mon, 29 Mar 2021 02:27:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jeJ01GXy"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 473CD602D2 for ; Mon, 29 Mar 2021 02:27:29 +0200 (CEST) Received: by mail-pl1-x634.google.com with SMTP id l1so3573470plg.12 for ; Sun, 28 Mar 2021 17:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qN4zyYtjze+RpnIPIXlkhNzNPt6huMpyeir3TFZj5MU=; b=jeJ01GXy7v9UaPcTs8rgCvKr/4rJTdUsxpB1P2BPZ8DCi4xKogd+HJFhxNQHKw76c7 ykxk8/5ANXocIVLZVEzTKHDsULh8pxSozl4LRx8e5Md13bda3u9TOtt6/xdK1rWwpVJR hqMumJCkWMxX11mZ2nIrr18L0APwF3uaQzFhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qN4zyYtjze+RpnIPIXlkhNzNPt6huMpyeir3TFZj5MU=; b=Wxv4Uvgmx7Ki0rAdVduJBSSexcBs94c/3DVIjwQV75WYVD3EWEcmxNzZQCih7q9WGe 0O6dpkr4Ppp8pr11iC6SMxiWQXXVpvbpe+4CYkdVDB+XkTOLa7NHyXJzWfA6jz4AzvXe aesCxv3fGwbVB8Cj+OkiCB4+1mHXbXcdQtfHRkt5w4BWBtmUZAwwAsA4RpKwBiAIANL1 ynjnX3FILIjHjYMRDm5ESqEM5jZhPnmusyelNGVgZxd5UyWZO5nams8S30GT7V25h3PB YkZ5lCLMQFV5EgZssA3RDSbFW+bX+X1ZOgwac/7IWK134Jwmkp7DPb4Pf1hWs54SKDXE xAVA== X-Gm-Message-State: AOAM533XmsM8vNlgaly34GNpg81ByU7v6XHIn8R0N1em+TL5m5PK/e2H v7AyjNpzEfB+kNGA7yEBpnnyOpq0h3eseQ== X-Google-Smtp-Source: ABdhPJzGZXQ/V5PiDltlP5G0Ljpoj4pTWmm4JwVBY5GvJneqxOS/P4zScEy3SH9aMKzSIF5oeSeftw== X-Received: by 2002:a17:902:9897:b029:e6:f01d:9ca1 with SMTP id s23-20020a1709029897b02900e6f01d9ca1mr26443643plp.40.1616977647412; Sun, 28 Mar 2021 17:27:27 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id j188sm15227209pfd.64.2021.03.28.17.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 17:27:27 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 09:27:15 +0900 Message-Id: <20210329002715.74403-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210329002715.74403-1-hiroh@chromium.org> References: <20210329002715.74403-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] Regard a request error in the request completion X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera::Request contains an error value. Every libcamera::Camera client should regards the error in a request completion. Signed-off-by: Hirokazu Honda --- Documentation/guides/application-developer.rst | 4 ++-- src/android/camera_device.cpp | 6 ++++-- src/cam/capture.cpp | 4 +++- src/gstreamer/gstlibcamerasrc.cpp | 4 ++++ src/qcam/main_window.cpp | 4 +++- src/v4l2/v4l2_camera.cpp | 4 +++- test/camera/buffer_import.cpp | 4 +++- test/camera/capture.cpp | 4 +++- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index e3430f03..d7232e7c 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -384,13 +384,13 @@ Request completion events can be emitted for requests which have been canceled, for example, by unexpected application shutdown. To avoid an application processing invalid image data, it’s worth checking that the request has completed successfully. The list of request completion statuses is available in -the `Request::Status`_ class enum documentation. +the `Request::Status`_ class enum documentation and `Request::result`_. .. _Request::Status: https://www.libcamera.org/api-html/classlibcamera_1_1Request.html#a2209ba8d51af8167b25f6e3e94d5c45b .. code:: cpp - if (request->status() == Request::RequestCancelled) + if (request->status() == Request::RequestCancelled || request->result() != 0) return; If the ``Request`` has completed successfully, applications can access the diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..d02c1776 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1908,9 +1908,11 @@ void CameraDevice::requestComplete(Request *request) Camera3RequestDescriptor *descriptor = reinterpret_cast(request->cookie()); - if (request->status() != Request::RequestComplete) { + if (request->status() != Request::RequestComplete || + request->result() != 0) { LOG(HAL, Error) << "Request not successfully completed: " - << request->status(); + << "status=" << request->status() + << ", result=" << request->result(); status = CAMERA3_BUFFER_STATUS_ERROR; } diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp index 7b55fc67..24d0be32 100644 --- a/src/cam/capture.cpp +++ b/src/cam/capture.cpp @@ -165,8 +165,10 @@ int Capture::queueRequest(Request *request) void Capture::requestComplete(Request *request) { - if (request->status() == Request::RequestCancelled) + if (request->status() == Request::RequestCancelled || + request->result() != 0) { return; + } /* * Defer processing of the completed request to the event loop, to avoid diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 87246b40..b36ac33c 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -167,6 +167,10 @@ GstLibcameraSrcState::requestCompleted(Request *request) GST_DEBUG_OBJECT(src_, "Request was cancelled"); return; } + if (request->result() != 0) { + GST_DEBUG_OBJECT(src_, "Request was not completed successfully"); + return; + } GstBuffer *buffer; for (GstPad *srcpad : srcpads_) { diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 39d034de..f90310f9 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -692,8 +692,10 @@ void MainWindow::processRaw(FrameBuffer *buffer, void MainWindow::requestComplete(Request *request) { - if (request->status() == Request::RequestCancelled) + if (request->status() == Request::RequestCancelled || + request->result() != 0) { return; + } /* * We're running in the libcamera thread context, expensive operations diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 97825c71..87153cd4 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -82,8 +82,10 @@ std::vector V4L2Camera::completedBuffers() void V4L2Camera::requestComplete(Request *request) { - if (request->status() == Request::RequestCancelled) + if (request->status() == Request::RequestCancelled || + request->result() != 0) { return; + } /* We only have one stream at the moment. */ bufferLock_.lock(); diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp index 61f4eb92..8f4efa5e 100644 --- a/test/camera/buffer_import.cpp +++ b/test/camera/buffer_import.cpp @@ -47,8 +47,10 @@ protected: void requestComplete(Request *request) { - if (request->status() != Request::RequestComplete) + if (request->status() != Request::RequestComplete || + request->result() != 0) { return; + } const Request::BufferMap &buffers = request->buffers(); diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp index c4bc2110..6cff9bb4 100644 --- a/test/camera/capture.cpp +++ b/test/camera/capture.cpp @@ -43,8 +43,10 @@ protected: void requestComplete(Request *request) { - if (request->status() != Request::RequestComplete) + if (request->status() != Request::RequestComplete || + request->result() != 0) { return; + } const Request::BufferMap &buffers = request->buffers();