diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-05 18:48:38 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-22 17:13:45 +0300 |
commit | 34d986d1ec342e84db0302d28b7d8bc98c2cd054 (patch) | |
tree | 47df9eb80968a61ea99872c665655dd079dbe32d /src/cam/main.cpp | |
parent | 24ca846a27d3b5f3e371dcd039df6ee74dd113c1 (diff) |
cam: Store camera session pointer in CamApp class
Move the local CameraSession variable from the CamApp::run() function to
a member variable of the CamApp class, created in CamApp::init(). This
is a first step towards moving code to the CameraSession class.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/cam/main.cpp')
-rw-r--r-- | src/cam/main.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index b13230c3..2c6500a5 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -51,8 +51,11 @@ private: static CamApp *app_; OptionsParser::Options options_; CameraManager *cm_; + std::shared_ptr<Camera> camera_; std::unique_ptr<libcamera::CameraConfiguration> config_; + std::unique_ptr<CameraSession> session_; + EventLoop loop_; bool strictFormats_; @@ -127,6 +130,9 @@ int CamApp::init(int argc, char **argv) cleanup(); return ret; } + + session_ = std::make_unique<CameraSession>(camera_, config_.get()); + session_->captureDone.connect(this, &CamApp::captureDone); } if (options_.isSet(OptMonitor)) { @@ -369,10 +375,12 @@ int CamApp::run() } if (options_.isSet(OptCapture)) { - CameraSession session(camera_, config_.get()); - session.captureDone.connect(this, &CamApp::captureDone); + if (!camera_) { + std::cout << "Can't capture without a camera" << std::endl; + return -ENODEV; + } - ret = session.start(options_); + ret = session_->start(options_); if (ret) { std::cout << "Failed to start camera session" << std::endl; return ret; @@ -380,7 +388,7 @@ int CamApp::run() loop_.exec(); - session.stop(); + session_->stop(); return 0; } |