diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-05 06:59:21 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-22 17:13:40 +0300 |
commit | 453583e189e01bbef321b9a50c0c435cc05fef63 (patch) | |
tree | 1aed1e3b07e9bb2e1273e3e42c7ef9d6df2394b0 /src/cam/camera_session.cpp | |
parent | 94d828d880492617c936434a5ca93ee83366a31b (diff) |
cam: camera_session: Access event loop through global instance
Don't pass the event loop to the CameraSession constructor, as passing
this global object explicitly isn't a design that can scale.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/cam/camera_session.cpp')
-rw-r--r-- | src/cam/camera_session.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index 439dcdb2..b26c7974 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -13,13 +13,14 @@ #include <libcamera/control_ids.h> #include "camera_session.h" +#include "event_loop.h" #include "main.h" using namespace libcamera; CameraSession::CameraSession(std::shared_ptr<Camera> camera, - CameraConfiguration *config, EventLoop *loop) - : camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop), + CameraConfiguration *config) + : camera_(camera), config_(config), writer_(nullptr), last_(0), queueCount_(0), captureCount_(0), captureLimit_(0), printMetadata_(false) { @@ -145,7 +146,7 @@ int CameraSession::capture(FrameBufferAllocator *allocator) else std::cout << "Capture until user interrupts by SIGINT" << std::endl; - ret = loop_->exec(); + ret = EventLoop::instance()->exec(); if (ret) std::cout << "Failed to run capture loop" << std::endl; @@ -175,7 +176,7 @@ void CameraSession::requestComplete(Request *request) * Defer processing of the completed request to the event loop, to avoid * blocking the camera manager thread. */ - loop_->callLater([=]() { processRequest(request); }); + EventLoop::instance()->callLater([=]() { processRequest(request); }); } void CameraSession::processRequest(Request *request) @@ -231,7 +232,7 @@ void CameraSession::processRequest(Request *request) captureCount_++; if (captureLimit_ && captureCount_ >= captureLimit_) { - loop_->exit(0); + EventLoop::instance()->exit(0); return; } |