{"id":1029,"url":"https://patchwork.libcamera.org/api/patches/1029/?format=json","web_url":"https://patchwork.libcamera.org/patch/1029/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190417135858.23914-7-jacopo@jmondi.org>","date":"2019-04-17T13:58:56","name":"[libcamera-devel,v7,6/8] libcamera: camera: Validate Request before queueing it","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"08bd9cdd2be764a1c7dfb5155c7f51f77d0a981e","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1029/mbox/","series":[{"id":254,"url":"https://patchwork.libcamera.org/api/series/254/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=254","date":"2019-04-17T13:58:50","name":"libcamera: Framework changes to prepare for multiple streams support","version":7,"mbox":"https://patchwork.libcamera.org/series/254/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1029/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1029/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EDF460DBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 15:58:20 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id D2F9940004;\n\tWed, 17 Apr 2019 13:58:19 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 17 Apr 2019 15:58:56 +0200","Message-Id":"<20190417135858.23914-7-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190417135858.23914-1-jacopo@jmondi.org>","References":"<20190417135858.23914-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 6/8] libcamera: camera: Validate\n\tRequest before queueing it","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Wed, 17 Apr 2019 13:58:20 -0000"},"content":"Extend the Request::prepare() operation to validate the request before\npreparing it. Return an error if the request is invalid, which for now\nis limited to ensuring that the request contains at least one buffer.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera.cpp  | 11 ++++++++---\n src/libcamera/request.cpp | 12 +++++++++++-\n 2 files changed, 19 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 2d0a80664214..75a21008070b 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -713,9 +713,14 @@ Request *Camera::createRequest()\n  * \\brief Queue a request to the camera\n  * \\param[in] request The request to queue to the camera\n  *\n- * This method queues a \\a request allocated with createRequest() to the camera\n- * for capture. Once the request has been queued, the camera will notify its\n- * completion through the \\ref requestCompleted signal.\n+ * This method queues a \\a request to the camera for capture.\n+ *\n+ * After allocating the request with createRequest(), the application shall\n+ * fill it with at least one capture buffer before queuing it. Requests that\n+ * contain no buffers are invalid and are rejected without being queued.\n+ *\n+ * Once the request has been queued, the camera will notify its completion\n+ * through the \\ref requestCompleted signal.\n  *\n  * Ownership of the request is transferred to the camera. It will be deleted\n  * automatically after it completes.\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex e5c25d2c6988..9fc8c6845578 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -115,10 +115,20 @@ Buffer *Request::findBuffer(Stream *stream) const\n  */\n \n /**\n- * \\brief Prepare the resources for the completion handler\n+ * \\brief Validate the request and prepare it for the completion handler\n+ *\n+ * Requests that contain no buffers are invalid and are rejected.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EINVAL The request is invalid\n  */\n int Request::prepare()\n {\n+\tif (!hasPendingBuffers()) {\n+\t\tLOG(Request, Error) << \"Invalid request due to missing buffers\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \tfor (auto const &pair : bufferMap_) {\n \t\tBuffer *buffer = pair.second;\n \t\tpending_.insert(buffer);\n","prefixes":["libcamera-devel","v7","6/8"]}