mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 10:25:05 +03:00
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>
This commit is contained in:
parent
66c955648f
commit
a2c634d449
1 changed files with 14 additions and 16 deletions
|
@ -47,7 +47,6 @@ private:
|
||||||
OptionsParser::Options options_;
|
OptionsParser::Options options_;
|
||||||
|
|
||||||
std::unique_ptr<CameraManager> cm_;
|
std::unique_ptr<CameraManager> cm_;
|
||||||
std::unique_ptr<CameraSession> session_;
|
|
||||||
|
|
||||||
EventLoop loop_;
|
EventLoop loop_;
|
||||||
};
|
};
|
||||||
|
@ -86,8 +85,6 @@ int CamApp::init(int argc, char **argv)
|
||||||
|
|
||||||
void CamApp::cleanup()
|
void CamApp::cleanup()
|
||||||
{
|
{
|
||||||
session_.reset();
|
|
||||||
|
|
||||||
cm_->stop();
|
cm_->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +169,7 @@ void CamApp::captureDone()
|
||||||
|
|
||||||
int CamApp::run()
|
int CamApp::run()
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<CameraSession> session;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (options_.isSet(OptList)) {
|
if (options_.isSet(OptList)) {
|
||||||
|
@ -185,55 +183,55 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptCamera)) {
|
if (options_.isSet(OptCamera)) {
|
||||||
session_ = std::make_unique<CameraSession>(cm_.get(), options_);
|
session = std::make_unique<CameraSession>(cm_.get(), options_);
|
||||||
if (!session_->isValid()) {
|
if (!session->isValid()) {
|
||||||
std::cout << "Failed to create camera session" << std::endl;
|
std::cout << "Failed to create camera session" << std::endl;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Using camera " << session_->camera()->id()
|
std::cout << "Using camera " << session->camera()->id()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
session_->captureDone.connect(this, &CamApp::captureDone);
|
session->captureDone.connect(this, &CamApp::captureDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptListControls)) {
|
if (options_.isSet(OptListControls)) {
|
||||||
if (!session_) {
|
if (!session) {
|
||||||
std::cout << "Cannot list controls without a camera"
|
std::cout << "Cannot list controls without a camera"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->listControls();
|
session->listControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptListProperties)) {
|
if (options_.isSet(OptListProperties)) {
|
||||||
if (!session_) {
|
if (!session) {
|
||||||
std::cout << "Cannot list properties without a camera"
|
std::cout << "Cannot list properties without a camera"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->listProperties();
|
session->listProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptInfo)) {
|
if (options_.isSet(OptInfo)) {
|
||||||
if (!session_) {
|
if (!session) {
|
||||||
std::cout << "Cannot print stream information without a camera"
|
std::cout << "Cannot print stream information without a camera"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->infoConfiguration();
|
session->infoConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptCapture)) {
|
if (options_.isSet(OptCapture)) {
|
||||||
if (!session_) {
|
if (!session) {
|
||||||
std::cout << "Can't capture without a camera" << std::endl;
|
std::cout << "Can't capture without a camera" << std::endl;
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = session_->start(options_);
|
ret = session->start(options_);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
std::cout << "Failed to start camera session" << std::endl;
|
std::cout << "Failed to start camera session" << std::endl;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -241,7 +239,7 @@ int CamApp::run()
|
||||||
|
|
||||||
loop_.exec();
|
loop_.exec();
|
||||||
|
|
||||||
session_->stop();
|
session->stop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue