summaryrefslogtreecommitdiff
path: root/src/cam
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-11-08 02:01:23 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-11-15 22:21:32 +0200
commit02eae70e15bdbb24a6a4eec74313d6ef616188bc (patch)
tree4e7ff18d9fc48b7104b86bd7efbf3294e3dc4836 /src/cam
parentf49e93338b6309a66b558dea40d114925f01e993 (diff)
cam: Move request processing to main thread
The request completion handler is invoked in the camera manager thread, which shouldn't be blocked for large amounts of time. As writing the frames to disk can be a time-consuming process, move request processing to the main thread by queueing an event to the event loop. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/cam')
-rw-r--r--src/cam/capture.cpp9
-rw-r--r--src/cam/capture.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
index 7580f798..113ea49d 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/capture.cpp
@@ -157,6 +157,15 @@ void Capture::requestComplete(Request *request)
if (request->status() == Request::RequestCancelled)
return;
+ /*
+ * Defer processing of the completed request to the event loop, to avoid
+ * blocking the camera manager thread.
+ */
+ loop_->callLater([=]() { processRequest(request); });
+}
+
+void Capture::processRequest(Request *request)
+{
const Request::BufferMap &buffers = request->buffers();
/*
diff --git a/src/cam/capture.h b/src/cam/capture.h
index 45e5e8a9..d21c95a2 100644
--- a/src/cam/capture.h
+++ b/src/cam/capture.h
@@ -33,6 +33,7 @@ private:
int capture(libcamera::FrameBufferAllocator *allocator);
void requestComplete(libcamera::Request *request);
+ void processRequest(libcamera::Request *request);
std::shared_ptr<libcamera::Camera> camera_;
libcamera::CameraConfiguration *config_;