summaryrefslogtreecommitdiff
path: root/src/cam/main.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-10-25 14:40:50 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-11-15 22:21:23 +0200
commit7d35c771c0480e1ca5942ba3c9cf09c1fde22f85 (patch)
tree5de606b9a2a09fa58abf1f063a106b1cc9b4e1a6 /src/cam/main.cpp
parenta27057fc503de6b8e1fb67bfe704dba80b51bfd8 (diff)
cam: Use libevent to implement event loop
To prepare for removal of the EventDispatcher from the libcamera public API, switch to libevent to handle the event loop. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/cam/main.cpp')
-rw-r--r--src/cam/main.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index b3a8d94f..e01be63a 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -52,7 +52,7 @@ private:
CameraManager *cm_;
std::shared_ptr<Camera> camera_;
std::unique_ptr<libcamera::CameraConfiguration> config_;
- EventLoop *loop_;
+ EventLoop loop_;
bool strictFormats_;
};
@@ -60,7 +60,7 @@ private:
CamApp *CamApp::app_ = nullptr;
CamApp::CamApp()
- : cm_(nullptr), camera_(nullptr), config_(nullptr), loop_(nullptr),
+ : cm_(nullptr), camera_(nullptr), config_(nullptr),
strictFormats_(false)
{
CamApp::app_ = this;
@@ -134,16 +134,11 @@ int CamApp::init(int argc, char **argv)
std::cout << "Monitoring new hotplug and unplug events" << std::endl;
}
- loop_ = new EventLoop(cm_->eventDispatcher());
-
return 0;
}
void CamApp::cleanup()
{
- delete loop_;
- loop_ = nullptr;
-
if (camera_) {
camera_->release();
camera_.reset();
@@ -166,8 +161,7 @@ int CamApp::exec()
void CamApp::quit()
{
- if (loop_)
- loop_->exit();
+ loop_.exit();
}
int CamApp::parseOptions(int argc, char *argv[])
@@ -366,13 +360,13 @@ int CamApp::run()
}
if (options_.isSet(OptCapture)) {
- Capture capture(camera_, config_.get(), loop_);
+ Capture capture(camera_, config_.get(), &loop_);
return capture.run(options_);
}
if (options_.isSet(OptMonitor)) {
std::cout << "Press Ctrl-C to interrupt" << std::endl;
- ret = loop_->exec();
+ ret = loop_.exec();
if (ret)
std::cout << "Failed to run monitor loop" << std::endl;
}