{"id":662,"url":"https://patchwork.libcamera.org/api/1.1/patches/662/?format=json","web_url":"https://patchwork.libcamera.org/patch/662/","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":"<20190228162913.6508-10-laurent.pinchart@ideasonboard.com>","date":"2019-02-28T16:29:12","name":"[libcamera-devel,09/10] libcamera: Handle request completion explicitly in pipeline handlers","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b61b1b40424ab3a97200d4803050d6e76f366d2b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/662/mbox/","series":[{"id":196,"url":"https://patchwork.libcamera.org/api/1.1/series/196/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=196","date":"2019-02-28T16:29:03","name":"Rework request completion handling","version":1,"mbox":"https://patchwork.libcamera.org/series/196/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/662/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/662/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36F73610EF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:28 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C1C4C49\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:27 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551371367;\n\tbh=1/4lmarB6jmPzfh5dpVsG/s3fBP8xRDX8j37UMQLCrU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=mUKSw1CPqWrzHRHAtTMY8GfRXhuL0KOQHCfgL9FnYiyMXIVPT1DO6aQnNoRQ8iZW/\n\tsnoHDzEFZtRXo1gUWiz6xsp5VudFjrcjirBNrlOD6EQbpkPIOPXMcoVkZqVSmj5kUc\n\tNb4jZ6nUW3elpJTrAMhUOgFD9JZNIugn9ImeGOEI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Feb 2019 18:29:12 +0200","Message-Id":"<20190228162913.6508-10-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 09/10] libcamera: Handle request\n\tcompletion explicitly in pipeline handlers","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":"Thu, 28 Feb 2019 16:29:29 -0000"},"content":"Request complete by themselves when all the buffers they contain have\ncompleted, connecting the buffer's completed signal to be notified of\nbuffer completion. While this works for now, it prevents pipelines from\ndelaying request completion until all metadata is available, and makes\nit impossible to ensure that requests complete in the order they are\nqueued.\n\nTo fix this, make request completion handling explicit in pipeline\nhandlers. The base PipelineHandler class is extended with\nimplementations of the queueRequest() and stop() methods and gets new\ncompleteBuffer() and completeRequest() methods to help pipeline handlers\ntracking requests and buffers.\n\nThe three existing pipeline handlers connect the bufferReady signal of\ntheir capture video node to a slot of their respective camera data\ninstance, where they use the PipelineHandler helpers to notify buffer\nand request completion. Request completion is handled synchronously with\nbuffer completion as the pipeline handlers don't need to support more\nadvanced use cases, but this paves the road for future work.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/buffer.h               |  5 +-\n include/libcamera/camera.h               |  3 +\n include/libcamera/request.h              |  4 +-\n src/libcamera/buffer.cpp                 |  5 --\n src/libcamera/camera.cpp                 | 21 ++++++\n src/libcamera/include/pipeline_handler.h | 10 ++-\n src/libcamera/pipeline/ipu3/ipu3.cpp     | 18 ++++-\n src/libcamera/pipeline/uvcvideo.cpp      | 19 ++++-\n src/libcamera/pipeline/vimc.cpp          | 19 ++++-\n src/libcamera/pipeline_handler.cpp       | 93 +++++++++++++++++++++++-\n src/libcamera/request.cpp                | 30 +++-----\n src/libcamera/v4l2_device.cpp            |  3 -\n 12 files changed, 192 insertions(+), 38 deletions(-)","diff":"diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex f740ade9bb4f..0c844d126a27 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -10,8 +10,6 @@\n #include <stdint.h>\n #include <vector>\n \n-#include <libcamera/signal.h>\n-\n namespace libcamera {\n \n class BufferPool;\n@@ -55,10 +53,9 @@ public:\n \tStatus status() const { return status_; }\n \tstd::vector<Plane> &planes() { return planes_; }\n \n-\tSignal<Buffer *> completed;\n-\n private:\n \tfriend class BufferPool;\n+\tfriend class PipelineHandler;\n \tfriend class V4L2Device;\n \n \tvoid cancel();\ndiff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex bf70255a6a5e..74eca3d86094 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -34,6 +34,7 @@ public:\n \n \tconst std::string &name() const;\n \n+\tSignal<Request *, Buffer *> bufferCompleted;\n \tSignal<Request *, const std::map<Stream *, Buffer *> &> requestCompleted;\n \tSignal<Camera *> disconnected;\n \n@@ -62,6 +63,8 @@ private:\n \tvoid disconnect();\n \tint exclusiveAccess();\n \n+\tvoid requestComplete(Request *request);\n+\n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::string name_;\n \tstd::vector<Stream *> streams_;\ndiff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 0b75f9d9bd19..0dbd425115e8 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -39,10 +39,12 @@ public:\n \n private:\n \tfriend class Camera;\n+\tfriend class PipelineHandler;\n \n \tint prepare();\n \tvoid complete(Status status);\n-\tvoid bufferCompleted(Buffer *buffer);\n+\n+\tbool completeBuffer(Buffer *buffer);\n \n \tCamera *camera_;\n \tstd::map<Stream *, Buffer *> bufferMap_;\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex 524eb47d4364..e2d1cf04411e 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -212,11 +212,6 @@ Buffer::Buffer()\n  * \\return A reference to a vector holding all Planes within the buffer\n  */\n \n-/**\n- * \\var Buffer::completed\n- * \\brief A Signal to provide notifications that the specific Buffer is ready\n- */\n-\n /**\n  * \\fn Buffer::bytesused()\n  * \\brief Retrieve the number of bytes occupied by the data in the buffer\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 3789732b95d1..3ef760943ff9 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -98,6 +98,12 @@ const std::string &Camera::name() const\n \treturn name_;\n }\n \n+/**\n+ * \\var Camera::bufferCompleted\n+ * \\brief Signal emitted when a buffer for a request queued to the camera has\n+ * completed\n+ */\n+\n /**\n  * \\var Camera::requestCompleted\n  * \\brief Signal emitted when a request queued to the camera has completed\n@@ -421,4 +427,19 @@ int Camera::exclusiveAccess()\n \treturn 0;\n }\n \n+/**\n+ * \\brief Handle request completion and notify application\n+ * \\param[in] request The request that has completed\n+ *\n+ * This function is called by the pipeline handler to notify the camera that\n+ * the request has completed. It emits the requestCompleted signal and deletes\n+ * the request.\n+ */\n+void Camera::requestComplete(Request *request)\n+{\n+\tstd::map<Stream *, Buffer *> buffers(std::move(request->bufferMap_));\n+\trequestCompleted.emit(request, buffers);\n+\tdelete request;\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex b2b9c94cebdc..cbc953696816 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_PIPELINE_HANDLER_H__\n #define __LIBCAMERA_PIPELINE_HANDLER_H__\n \n+#include <list>\n #include <map>\n #include <memory>\n #include <string>\n@@ -14,6 +15,7 @@\n \n namespace libcamera {\n \n+class Buffer;\n class BufferPool;\n class Camera;\n class CameraManager;\n@@ -35,6 +37,7 @@ public:\n \n \tCamera *camera_;\n \tPipelineHandler *pipe_;\n+\tstd::list<Request *> queuedRequests_;\n \n private:\n \tCameraData(const CameraData &) = delete;\n@@ -58,9 +61,12 @@ public:\n \tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n \n \tvirtual int start(Camera *camera) = 0;\n-\tvirtual void stop(Camera *camera) = 0;\n+\tvirtual void stop(Camera *camera);\n \n-\tvirtual int queueRequest(Camera *camera, Request *request) = 0;\n+\tvirtual int queueRequest(Camera *camera, Request *request);\n+\n+\tbool completeBuffer(Camera *camera, Request *request, Buffer *buffer);\n+\tvoid completeRequest(Camera *camera, Request *request);\n \n protected:\n \tvoid registerCamera(std::shared_ptr<Camera> camera,\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 776b7f07f78d..4695ec99470e 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -63,6 +63,8 @@ private:\n \t\t\tdelete sensor_;\n \t\t}\n \n+\t\tvoid bufferReady(Buffer *buffer);\n+\n \t\tV4L2Device *cio2_;\n \t\tV4L2Subdevice *csi2_;\n \t\tV4L2Subdevice *sensor_;\n@@ -236,6 +238,8 @@ void PipelineHandlerIPU3::stop(Camera *camera)\n \n \tif (data->cio2_->streamOff())\n \t\tLOG(IPU3, Info) << \"Failed to stop camera \" << camera->name();\n+\n+\tPipelineHandler::stop(camera);\n }\n \n int PipelineHandlerIPU3::queueRequest(Camera *camera, Request *request)\n@@ -250,7 +254,11 @@ int PipelineHandlerIPU3::queueRequest(Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tdata->cio2_->queueBuffer(buffer);\n+\tint ret = data->cio2_->queueBuffer(buffer);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tPipelineHandler::queueRequest(camera, request);\n \n \treturn 0;\n }\n@@ -417,6 +425,14 @@ void PipelineHandlerIPU3::registerCameras()\n \t}\n }\n \n+void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)\n+{\n+\tRequest *request = queuedRequests_.front();\n+\n+\tpipe_->completeBuffer(camera_, request, buffer);\n+\tpipe_->completeRequest(camera_, request);\n+}\n+\n REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3);\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex f121d3c5633e..29c0c25ae7a8 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -56,6 +56,8 @@ private:\n \t\t\tdelete video_;\n \t\t}\n \n+\t\tvoid bufferReady(Buffer *buffer);\n+\n \t\tV4L2Device *video_;\n \t\tStream stream_;\n \t};\n@@ -153,6 +155,7 @@ void PipelineHandlerUVC::stop(Camera *camera)\n {\n \tUVCCameraData *data = cameraData(camera);\n \tdata->video_->streamOff();\n+\tPipelineHandler::stop(camera);\n }\n \n int PipelineHandlerUVC::queueRequest(Camera *camera, Request *request)\n@@ -166,7 +169,11 @@ int PipelineHandlerUVC::queueRequest(Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tdata->video_->queueBuffer(buffer);\n+\tint ret = data->video_->queueBuffer(buffer);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tPipelineHandler::queueRequest(camera, request);\n \n \treturn 0;\n }\n@@ -198,6 +205,8 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\n \n+\tdata->video_->bufferReady.connect(data.get(), &UVCCameraData::bufferReady);\n+\n \t/* Create and register the camera. */\n \tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model(), streams);\n@@ -209,6 +218,14 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \treturn true;\n }\n \n+void PipelineHandlerUVC::UVCCameraData::bufferReady(Buffer *buffer)\n+{\n+\tRequest *request = queuedRequests_.front();\n+\n+\tpipe_->completeBuffer(camera_, request, buffer);\n+\tpipe_->completeRequest(camera_, request);\n+}\n+\n REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC);\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 6d022c37eb9f..8c7c2d05828f 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -56,6 +56,8 @@ private:\n \t\t\tdelete video_;\n \t\t}\n \n+\t\tvoid bufferReady(Buffer *buffer);\n+\n \t\tV4L2Device *video_;\n \t\tStream stream_;\n \t};\n@@ -153,6 +155,7 @@ void PipelineHandlerVimc::stop(Camera *camera)\n {\n \tVimcCameraData *data = cameraData(camera);\n \tdata->video_->streamOff();\n+\tPipelineHandler::stop(camera);\n }\n \n int PipelineHandlerVimc::queueRequest(Camera *camera, Request *request)\n@@ -166,7 +169,11 @@ int PipelineHandlerVimc::queueRequest(Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tdata->video_->queueBuffer(buffer);\n+\tint ret = data->video_->queueBuffer(buffer);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tPipelineHandler::queueRequest(camera, request);\n \n \treturn 0;\n }\n@@ -205,6 +212,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \tif (data->video_->open())\n \t\treturn false;\n \n+\tdata->video_->bufferReady.connect(data.get(), &VimcCameraData::bufferReady);\n+\n \t/* Create and register the camera. */\n \tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, \"VIMC Sensor B\",\n@@ -214,6 +223,14 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \treturn true;\n }\n \n+void PipelineHandlerVimc::VimcCameraData::bufferReady(Buffer *buffer)\n+{\n+\tRequest *request = queuedRequests_.front();\n+\n+\tpipe_->completeBuffer(camera_, request, buffer);\n+\tpipe_->completeRequest(camera_, request);\n+}\n+\n REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc);\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 54f237942a48..1a858f2638ce 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -5,6 +5,7 @@\n  * pipeline_handler.cpp - Pipeline handler infrastructure\n  */\n \n+#include <libcamera/buffer.h>\n #include <libcamera/camera.h>\n #include <libcamera/camera_manager.h>\n \n@@ -74,6 +75,17 @@ LOG_DEFINE_CATEGORY(Pipeline)\n  * and remains valid until the instance is destroyed.\n  */\n \n+/**\n+ * \\var CameraData::queuedRequests_\n+ * \\brief The list of queued and not yet completed request\n+ *\n+ * The list of queued request is used to track requests queued in order to\n+ * ensure completion of all requests when the pipeline handler is stopped.\n+ *\n+ * \\sa PipelineHandler::queueRequest(), PipelineHandler::stop(),\n+ * PipelineHandler::completeRequest()\n+ */\n+\n /**\n  * \\class PipelineHandler\n  * \\brief Create and manage cameras based on a set of media devices\n@@ -226,8 +238,30 @@ PipelineHandler::~PipelineHandler()\n  * This method stops capturing and processing requests immediately. All pending\n  * requests are cancelled and complete immediately in an error state.\n  *\n- * \\todo Complete the pending requests immediately\n+ * Pipeline handlers shall override this method to stop the pipeline, ensure\n+ * that all pending request completion signaled through completeRequest() have\n+ * returned, and call the base implementation of the stop() method as the last\n+ * step of their implementation. The base implementation cancels all requests\n+ * queued but not yet complete.\n  */\n+void PipelineHandler::stop(Camera *camera)\n+{\n+\tCameraData *data = cameraData(camera);\n+\n+\twhile (!data->queuedRequests_.empty()) {\n+\t\tRequest *request = data->queuedRequests_.front();\n+\t\tdata->queuedRequests_.pop_front();\n+\n+\t\twhile (!request->pending_.empty()) {\n+\t\t\tBuffer *buffer = *request->pending_.begin();\n+\t\t\tbuffer->cancel();\n+\t\t\tcompleteBuffer(camera, request, buffer);\n+\t\t}\n+\n+\t\trequest->complete(Request::RequestCancelled);\n+\t\tcamera->requestComplete(request);\n+\t}\n+}\n \n /**\n  * \\fn PipelineHandler::queueRequest()\n@@ -241,8 +275,65 @@ PipelineHandler::~PipelineHandler()\n  * parameters will be applied to the frames captured in the buffers provided in\n  * the request.\n  *\n+ * Pipeline handlers shall override this method. The base implementation in the\n+ * PipelineHandler class keeps track of queued requests in order to ensure\n+ * completion of all requests when the pipeline handler is stopped with stop().\n+ * Requests completion shall be signaled by the pipeline handler using the\n+ * completeRequest() method.\n+ *\n  * \\return 0 on success or a negative error code otherwise\n  */\n+int PipelineHandler::queueRequest(Camera *camera, Request *request)\n+{\n+\tCameraData *data = cameraData(camera);\n+\tdata->queuedRequests_.push_back(request);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief Complete a buffer for a request\n+ * \\param[in] camera The camera the request belongs to\n+ * \\param[in] request The request the buffer belongs to\n+ * \\param[in] buffer The buffer that has completed\n+ *\n+ * This method shall be called by pipeline handlers to signal completion of the\n+ * \\a buffer part of the \\a request. It notifies applications of buffer\n+ * completion and updates the request's internal buffer tracking. The request\n+ * is not completed automatically when the last buffer completes, pipeline\n+ * handlers shall complete requests explicitly with completeRequest().\n+ *\n+ * \\return True if all buffers contained in the request have completed, false\n+ * otherwise\n+ */\n+bool PipelineHandler::completeBuffer(Camera *camera, Request *request,\n+\t\t\t\t     Buffer *buffer)\n+{\n+\tcamera->bufferCompleted.emit(request, buffer);\n+\treturn request->completeBuffer(buffer);\n+}\n+\n+/**\n+ * \\brief Signal request completion\n+ * \\param[in] camera The camera that the request belongs to\n+ * \\param[in] request The request that has completed\n+ *\n+ * The pipeline handler shall call this method to notify the \\a camera that the\n+ * request request has complete. The request is deleted and shall not be\n+ * accessed once this method returns.\n+ *\n+ * The pipeline handler shall ensure that requests complete in the same order\n+ * they are submitted.\n+ */\n+void PipelineHandler::completeRequest(Camera *camera, Request *request)\n+{\n+\tCameraData *data = cameraData(camera);\n+\tASSERT(request == data->queuedRequests_.front());\n+\tdata->queuedRequests_.pop_front();\n+\n+\trequest->complete(Request::RequestComplete);\n+\tcamera->requestComplete(request);\n+}\n \n /**\n  * \\brief Register a camera to the camera manager and pipeline handler\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex cb170930fbb6..e0e77e972411 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -113,7 +113,6 @@ int Request::prepare()\n {\n \tfor (auto const &pair : bufferMap_) {\n \t\tBuffer *buffer = pair.second;\n-\t\tbuffer->completed.connect(this, &Request::bufferCompleted);\n \t\tpending_.insert(buffer);\n \t}\n \n@@ -133,31 +132,24 @@ void Request::complete(Status status)\n }\n \n /**\n- * \\brief Slot for the buffer completed signal\n+ * \\brief Complete a buffer for the request\n+ * \\param[in] buffer The buffer that has completed\n  *\n- * The bufferCompleted method serves as slot where to connect the\n- * Buffer::completed signal that is emitted when a buffer has available\n- * data.\n+ * A request tracks the status of all buffers it contains through a set of\n+ * pending buffers. This function removes the \\a buffer from the set to mark it\n+ * as complete. All buffers associate with the request shall be marked as\n+ * complete by calling this function once and once only before reporting the\n+ * request as complete with the complete() method.\n  *\n- * The request completes when all the buffers it contains are ready to be\n- * presented to the application. It then emits the Camera::requestCompleted\n- * signal and is automatically deleted.\n+ * \\return True if all buffers contained in the request have completed, false\n+ * otherwise\n  */\n-void Request::bufferCompleted(Buffer *buffer)\n+bool Request::completeBuffer(Buffer *buffer)\n {\n-\tbuffer->completed.disconnect(this, &Request::bufferCompleted);\n-\n \tint ret = pending_.erase(buffer);\n \tASSERT(ret == 1);\n \n-\tif (!pending_.empty())\n-\t\treturn;\n-\n-\tcomplete(RequestComplete);\n-\n-\tstd::map<Stream *, Buffer *> buffers(std::move(bufferMap_));\n-\tcamera_->requestCompleted.emit(this, buffers);\n-\tdelete this;\n+\treturn pending_.empty();\n }\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 054499e4b888..52167a3e047f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -819,9 +819,6 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)\n \n \t/* Notify anyone listening to the device. */\n \tbufferReady.emit(buffer);\n-\n-\t/* Notify anyone listening to the buffer specifically. */\n-\tbuffer->completed.emit(buffer);\n }\n \n /**\n","prefixes":["libcamera-devel","09/10"]}