diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-07 02:16:03 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-22 17:13:54 +0300 |
commit | a2c634d4493231108159862c4f4ecdafff2b22e9 (patch) | |
tree | f7cc70e5438ddcc66f0a598de6c792524da07610 | |
parent | 66c955648febf926ce4e4e238d7f19d171619f5f (diff) |
cam: Move session_ member variable to a local variable in run() function
The session_ member of the CamApp class is only needed in the run()
function. Make it a local variable.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r-- | src/cam/main.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 4fe0c4c3..380c14e0 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -47,7 +47,6 @@ private: OptionsParser::Options options_; std::unique_ptr<CameraManager> cm_; - std::unique_ptr<CameraSession> session_; EventLoop loop_; }; @@ -86,8 +85,6 @@ int CamApp::init(int argc, char **argv) void CamApp::cleanup() { - session_.reset(); - cm_->stop(); } @@ -172,6 +169,7 @@ void CamApp::captureDone() int CamApp::run() { + std::unique_ptr<CameraSession> session; int ret; if (options_.isSet(OptList)) { @@ -185,55 +183,55 @@ int CamApp::run() } if (options_.isSet(OptCamera)) { - session_ = std::make_unique<CameraSession>(cm_.get(), options_); - if (!session_->isValid()) { + session = std::make_unique<CameraSession>(cm_.get(), options_); + if (!session->isValid()) { std::cout << "Failed to create camera session" << std::endl; return -EINVAL; } - std::cout << "Using camera " << session_->camera()->id() + std::cout << "Using camera " << session->camera()->id() << std::endl; - session_->captureDone.connect(this, &CamApp::captureDone); + session->captureDone.connect(this, &CamApp::captureDone); } if (options_.isSet(OptListControls)) { - if (!session_) { + if (!session) { std::cout << "Cannot list controls without a camera" << std::endl; return -EINVAL; } - session_->listControls(); + session->listControls(); } if (options_.isSet(OptListProperties)) { - if (!session_) { + if (!session) { std::cout << "Cannot list properties without a camera" << std::endl; return -EINVAL; } - session_->listProperties(); + session->listProperties(); } if (options_.isSet(OptInfo)) { - if (!session_) { + if (!session) { std::cout << "Cannot print stream information without a camera" << std::endl; return -EINVAL; } - session_->infoConfiguration(); + session->infoConfiguration(); } if (options_.isSet(OptCapture)) { - if (!session_) { + if (!session) { 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; @@ -241,7 +239,7 @@ int CamApp::run() loop_.exec(); - session_->stop(); + session->stop(); return 0; } |