From patchwork Mon Mar 29 09:15:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11764 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 D172DC32EA for ; Mon, 29 Mar 2021 09:16:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6E9986878A; Mon, 29 Mar 2021 11:16:08 +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="c3O/PQFz"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 30EE46877F for ; Mon, 29 Mar 2021 11:16:04 +0200 (CEST) Received: by mail-pj1-x1033.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so7890640pjb.1 for ; Mon, 29 Mar 2021 02:16:04 -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=F/R/Bikvglu/rqZgcIYTTJBemVCr6U4EhBeOlf3PuO4=; b=c3O/PQFzYMLQpfD7HAXz2Squ4O+F1OeDHLEb/9NqLF/fMi9Fo7ysLi+beeO7q/zv5e rTswXxZGonRR6um6wvLoxuDt/wcb9sYvhLDBWtgLCN6SPHUjDj9LEn4xQP9Sw+4NPg64 AGKFNshvJOhk3g75Ga26a6Q/rCoZPVYzP/Gvk= 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=F/R/Bikvglu/rqZgcIYTTJBemVCr6U4EhBeOlf3PuO4=; b=nRJnCqIl8Zj5dL+Aq8SoDVzdSNYwfAmigc5bG7ibY6vUd8RlesK07zTcJOeXh1exRk xN8DU3jvCuCimJTknmnOdSkM0VypbbAEJ6XI1kHbEw8s+kXeFw+LpZNl44jNAtmwpmnI wmcg9rYHfZIZkaomML+bckhCsGEMuAWx7vjit8cRazoFAZxyTwWvOQwn/jRzbRUP3wDz hHztcmYJuMNeiZYBrw3dl+eJb+fXK6l36zU6y4UM0gmnM+uIvY8cVJG76Yj27iEYCHQK R0kxVG+bNd4xL8GaV4rWWYNtYyOJPUAXtlyFoJianTmUxmEhml2jTwcWrDO50bfb94Mp JCuQ== X-Gm-Message-State: AOAM531w2CEFka+8lWjbHwCaK6kcCoTvUKSMv8i3OlwRX1abWTzB4BOm LEtr7ELF0FCRcn4KhW+OPB5o2Cp9GV4U/A== X-Google-Smtp-Source: ABdhPJwZv9kf4f9SJ/MJ2frPPpefoFTNI9ZjxyX8qTitmiqERf2m28HyzoddFE9kDsXxbM7FC10dzA== X-Received: by 2002:a17:90a:5d09:: with SMTP id s9mr25174803pji.228.1617009362647; Mon, 29 Mar 2021 02:16:02 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id n2sm15818122pga.57.2021.03.29.02.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 02:16:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 18:15:52 +0900 Message-Id: <20210329091552.157208-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210329091552.157208-1-hiroh@chromium.org> References: <20210329091552.157208-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 2 ++ src/cam/capture.cpp | 5 +++++ src/gstreamer/gstlibcamerasrc.cpp | 6 +++++- src/qcam/main_window.cpp | 4 ++++ src/v4l2/v4l2_camera.cpp | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index e3430f03..e8a1a7b4 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -392,6 +392,8 @@ the `Request::Status`_ class enum documentation. if (request->status() == Request::RequestCancelled) return; + if (request->status() == Request::RequestError) + // handle error. If the ``Request`` has completed successfully, applications can access the completed buffers using the ``Request::buffers()`` function, which returns a map diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp index 7b55fc67..3e9edf80 100644 --- a/src/cam/capture.cpp +++ b/src/cam/capture.cpp @@ -167,6 +167,11 @@ void Capture::requestComplete(Request *request) { if (request->status() == Request::RequestCancelled) return; + /* TODO: Handle an error correctly */ + if (request->status() == Request::RequestError) { + std::cout << "Failed to capture request: " << request->cookie(); + 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..1ecb9883 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -163,10 +163,14 @@ GstLibcameraSrcState::requestCompleted(Request *request) g_return_if_fail(wrap->request_.get() == request); - if ((request->status() == Request::RequestCancelled)) { + if (request->status() == Request::RequestCancelled) { GST_DEBUG_OBJECT(src_, "Request was cancelled"); return; } + if (request->status() == Request::RequestError) { + GST_ERROR_OBJECT(src_, "Request doesn't complete successfully"); + return; + } GstBuffer *buffer; for (GstPad *srcpad : srcpads_) { diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 39d034de..1288bcd5 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -694,6 +694,10 @@ void MainWindow::requestComplete(Request *request) { if (request->status() == Request::RequestCancelled) return; + if (request->status() == Request::RequestError) { + qCritical() << "Request doesn't complete successfully"; + 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..d6b1d755 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -84,6 +84,11 @@ void V4L2Camera::requestComplete(Request *request) { if (request->status() == Request::RequestCancelled) return; + if (request->status() == Request::RequestError) { + LOG(V4L2Compat, Error) + << "Request doesn't complete successfully"; + return; + } /* We only have one stream at the moment. */ bufferLock_.lock();