From b2c06cf40975398eb56be74fa3cd5d1b7b13cb50 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 28 Feb 2019 17:59:10 +0200 Subject: libcamera: Handle request completion explicitly in pipeline handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Request complete by themselves when all the buffers they contain have completed, connecting the buffer's completed signal to be notified of buffer completion. While this works for now, it prevents pipelines from delaying request completion until all metadata is available, and makes it impossible to ensure that requests complete in the order they are queued. To fix this, make request completion handling explicit in pipeline handlers. The base PipelineHandler class is extended with implementations of the queueRequest() and stop() methods and gets new completeBuffer() and completeRequest() methods to help pipeline handlers tracking requests and buffers. The three existing pipeline handlers connect the bufferReady signal of their capture video node to a slot of their respective camera data instance, where they use the PipelineHandler helpers to notify buffer and request completion. Request completion is handled synchronously with buffer completion as the pipeline handlers don't need to support more advanced use cases, but this paves the road for future work. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/buffer.h | 5 +---- include/libcamera/camera.h | 3 +++ include/libcamera/request.h | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index f740ade9..0c844d12 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -10,8 +10,6 @@ #include #include -#include - namespace libcamera { class BufferPool; @@ -55,10 +53,9 @@ public: Status status() const { return status_; } std::vector &planes() { return planes_; } - Signal completed; - private: friend class BufferPool; + friend class PipelineHandler; friend class V4L2Device; void cancel(); diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index e5212cf0..77e4cd1e 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -35,6 +35,7 @@ public: const std::string &name() const; + Signal bufferCompleted; Signal &> requestCompleted; Signal disconnected; @@ -73,6 +74,8 @@ private: friend class PipelineHandler; void disconnect(); + void requestComplete(Request *request); + std::shared_ptr pipe_; std::string name_; std::set streams_; diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 0b75f9d9..0dbd4251 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -39,10 +39,12 @@ public: private: friend class Camera; + friend class PipelineHandler; int prepare(); void complete(Status status); - void bufferCompleted(Buffer *buffer); + + bool completeBuffer(Buffer *buffer); Camera *camera_; std::map bufferMap_; -- cgit v1.2.1