From 02eae70e15bdbb24a6a4eec74313d6ef616188bc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 8 Nov 2020 02:01:23 +0200 Subject: cam: Move request processing to main thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/cam/capture.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/cam/capture.cpp') 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(); /* -- cgit v1.2.1