summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_manager.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-04 21:26:14 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-08 16:23:16 +0200
commit8356f8a6ab875680087032285c3b7bbfbdbddba9 (patch)
tree1288abd030c33fb9bb85c99eccabfe3958b3f7ce /src/libcamera/camera_manager.cpp
parent1a57bcb8d1a7a49cc8a43596a79d57cd2fbb5dfe (diff)
libcamera: Add a poll-based event dispatcher
Provide a poll-based event dispatcher implementation as convenience for applications that don't need a custom event loop. The poll-based dispatcher is automatically instantiated if the application doesn't provide its own dispatcher. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r--src/libcamera/camera_manager.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 6e1d5db1..be327f5d 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -9,6 +9,7 @@
#include <libcamera/event_dispatcher.h>
#include "device_enumerator.h"
+#include "event_dispatcher_poll.h"
#include "log.h"
#include "pipeline_handler.h"
@@ -188,9 +189,10 @@ CameraManager *CameraManager::instance()
* \param dispatcher Pointer to the event dispatcher
*
* libcamera requires an event dispatcher to integrate event notification and
- * timers with the application event loop. Applications shall call this function
- * once and only once before the camera manager is started with start() to set
- * the event dispatcher.
+ * timers with the application event loop. Applications that want to provide
+ * their own event dispatcher shall call this function once and only once before
+ * the camera manager is started with start(). If no event dispatcher is
+ * provided, a default poll-based implementation will be used.
*
* The CameraManager takes ownership of the event dispatcher and will delete it
* when the application terminates.
@@ -207,11 +209,18 @@ void CameraManager::setEventDispatcher(EventDispatcher *dispatcher)
/**
* \brief Retrieve the event dispatcher
- * \return Pointer to the event dispatcher, or nullptr if no event dispatcher
- * has been set
+ *
+ * This function retrieves the event dispatcher set with setEventDispatcher().
+ * If no dispatcher has been set, a default poll-based implementation is created
+ * and returned, and no custom event dispatcher may be installed anymore.
+ *
+ * \return Pointer to the event dispatcher
*/
EventDispatcher *CameraManager::eventDispatcher()
{
+ if (!dispatcher_)
+ dispatcher_ = new EventDispatcherPoll();
+
return dispatcher_;
}