From a2c634d4493231108159862c4f4ecdafff2b22e9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 7 Jul 2021 02:16:03 +0300 Subject: 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 Reviewed-by: Kieran Bingham --- src/cam/main.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') 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 cm_; - std::unique_ptr 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 session; int ret; if (options_.isSet(OptList)) { @@ -185,55 +183,55 @@ int CamApp::run() } if (options_.isSet(OptCamera)) { - session_ = std::make_unique(cm_.get(), options_); - if (!session_->isValid()) { + session = std::make_unique(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; } -- cgit v1.2.1