{"id":12243,"url":"https://patchwork.libcamera.org/api/1.1/patches/12243/?format=json","web_url":"https://patchwork.libcamera.org/patch/12243/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210510105235.28319-4-jacopo@jmondi.org>","date":"2021-05-10T10:52:30","name":"[libcamera-devel,3/8] libcamera: pipeline_handler: Notify Request queueing failure","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"79c0b914536624ba4c1cef76125c56c2bb09c726","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/12243/mbox/","series":[{"id":2016,"url":"https://patchwork.libcamera.org/api/1.1/series/2016/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2016","date":"2021-05-10T10:52:27","name":"android: Implement flush() camera operation","version":1,"mbox":"https://patchwork.libcamera.org/series/2016/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12243/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12243/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3EDD8BF831\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 May 2021 10:52:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E56968919;\n\tMon, 10 May 2021 12:52:01 +0200 (CEST)","from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 64128688E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 May 2021 12:51:58 +0200 (CEST)","from uno.homenet.telecomitalia.it\n\t(host-82-59-136-116.retail.telecomitalia.it [82.59.136.116])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id A1C07E01E6;\n\tMon, 10 May 2021 10:51:57 +0000 (UTC)"],"X-Originating-IP":"82.59.136.116","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 10 May 2021 12:52:30 +0200","Message-Id":"<20210510105235.28319-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210510105235.28319-1-jacopo@jmondi.org>","References":"<20210510105235.28319-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 3/8] libcamera: pipeline_handler: Notify\n\tRequest queueing failure","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Capture requests are queued by the PipelineHandler base class to each\npipeline handler implementation using the virtual queueRequestDevice()\nfunction.\n\nHowever, if the pipeline handler fails to queue the request to the\nhardware, the request gets silently deleted from the list of queued\nones, without notifying application of the error.\n\nAllowing applications to know if a Request has failed to queue\nby emitting the Camera::bufferCompleted and Camera::requestCompleted\nsignals allows them to maintain a state consistent with the one\ninternal to the library.\n\nTo do so, if queuing a request to the device fails, cancel the request\nand emit the completion signal to report the failure to applications.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline_handler.cpp | 15 ++++++++++++++-\n 1 file changed, 14 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex f41b7a7b3308..260a52018a4d 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -391,6 +391,8 @@ bool PipelineHandler::hasPendingRequests(const Camera *camera) const\n  * This method queues a capture request to the pipeline handler for processing.\n  * The request is first added to the internal list of queued requests, and\n  * then passed to the pipeline handler with a call to queueRequestDevice().\n+ * If the pipeline handler fails in queuing the request to the hardware the\n+ * request is immediately completed with error.\n  *\n  * Keeping track of queued requests ensures automatic completion of all requests\n  * when the pipeline handler is stopped with stop(). Request completion shall be\n@@ -409,8 +411,19 @@ void PipelineHandler::queueRequest(Request *request)\n \trequest->sequence_ = data->requestSequence_++;\n \n \tint ret = queueRequestDevice(camera, request);\n-\tif (ret)\n+\tif (ret) {\n+\t\t/*\n+\t\t * Cancel the request and notify completion of its buffers in\n+\t\t * error state. Then complete the cancelled request and remove\n+\t\t * it from the queued requests list.\n+\t\t */\n+\t\trequest->cancel();\n+\t\tfor (auto bufferMap : request->buffers())\n+\t\t\tcamera->bufferCompleted.emit(request, bufferMap.second);\n+\n+\t\tcamera->requestComplete(request);\n \t\tdata->queuedRequests_.remove(request);\n+\t}\n }\n \n /**\n","prefixes":["libcamera-devel","3/8"]}