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>
This commit is contained in:
parent
f49e93338b
commit
02eae70e15
2 changed files with 10 additions and 0 deletions
|
@ -157,6 +157,15 @@ void Capture::requestComplete(Request *request)
|
||||||
if (request->status() == Request::RequestCancelled)
|
if (request->status() == Request::RequestCancelled)
|
||||||
return;
|
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();
|
const Request::BufferMap &buffers = request->buffers();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -33,6 +33,7 @@ private:
|
||||||
int capture(libcamera::FrameBufferAllocator *allocator);
|
int capture(libcamera::FrameBufferAllocator *allocator);
|
||||||
|
|
||||||
void requestComplete(libcamera::Request *request);
|
void requestComplete(libcamera::Request *request);
|
||||||
|
void processRequest(libcamera::Request *request);
|
||||||
|
|
||||||
std::shared_ptr<libcamera::Camera> camera_;
|
std::shared_ptr<libcamera::Camera> camera_;
|
||||||
libcamera::CameraConfiguration *config_;
|
libcamera::CameraConfiguration *config_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue