summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_manager.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-03-23 17:33:15 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-11 09:47:16 +0300
commit525b19c4101235385148ff9358b7b6e778a1f148 (patch)
tree7e7f32764f418af456b343ad1dae7fb05dab032a /src/libcamera/camera_manager.cpp
parent10ec09025d6f52f2c1d0ba6b7e6943a603a386d9 (diff)
libcamera: Add thread support
The new Thread class wraps std::thread in order to integrate it with the Object, Signal and EventDispatcher classes. By default new threads run an internal event loop, and their run() method can be overloaded to provide a custom thread loop. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r--src/libcamera/camera_manager.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 337496c2..2cf01423 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -14,6 +14,7 @@
#include "event_dispatcher_poll.h"
#include "log.h"
#include "pipeline_handler.h"
+#include "thread.h"
#include "utils.h"
/**
@@ -56,7 +57,7 @@ LOG_DEFINE_CATEGORY(Camera)
*/
CameraManager::CameraManager()
- : enumerator_(nullptr), dispatcher_(nullptr)
+ : enumerator_(nullptr)
{
}
@@ -247,12 +248,7 @@ CameraManager *CameraManager::instance()
*/
void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher)
{
- if (dispatcher_) {
- LOG(Camera, Warning) << "Event dispatcher is already set";
- return;
- }
-
- dispatcher_ = std::move(dispatcher);
+ Thread::current()->setEventDispatcher(std::move(dispatcher));
}
/**
@@ -268,10 +264,7 @@ void CameraManager::setEventDispatcher(std::unique_ptr<EventDispatcher> dispatch
*/
EventDispatcher *CameraManager::eventDispatcher()
{
- if (!dispatcher_)
- dispatcher_ = utils::make_unique<EventDispatcherPoll>();
-
- return dispatcher_.get();
+ return Thread::current()->eventDispatcher();
}
} /* namespace libcamera */