diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-08-18 03:11:27 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-08-19 19:06:37 +0300 |
commit | fd0087b5d8608eb1dc1e1a3da5ddafd83d43fc79 (patch) | |
tree | ddaeac42ef501be42b40ab8cd40714cf107cfc0d | |
parent | 8c9deeb30fa6930019788b619ad9081d30c6a6e2 (diff) |
test: Get event dispatcher from current thread
For all tests that don't otherwise require access to the camera manager,
get the event dispatcher from the current thread instead of the camera
manager. This prepares for the removal of CameraManager::instance().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r-- | test/event-dispatcher.cpp | 4 | ||||
-rw-r--r-- | test/event.cpp | 4 | ||||
-rw-r--r-- | test/ipc/unixsocket.cpp | 6 | ||||
-rw-r--r-- | test/log/log_process.cpp | 4 | ||||
-rw-r--r-- | test/meson.build | 6 | ||||
-rw-r--r-- | test/object-invoke.cpp | 5 | ||||
-rw-r--r-- | test/process/process_test.cpp | 4 | ||||
-rw-r--r-- | test/timer.cpp | 4 | ||||
-rw-r--r-- | test/v4l2_videodevice/buffer_sharing.cpp | 4 | ||||
-rw-r--r-- | test/v4l2_videodevice/capture_async.cpp | 4 | ||||
-rw-r--r-- | test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 |
11 files changed, 24 insertions, 25 deletions
diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp index e8818dca..f243ec39 100644 --- a/test/event-dispatcher.cpp +++ b/test/event-dispatcher.cpp @@ -9,11 +9,11 @@ #include <signal.h> #include <sys/time.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "test.h" +#include "thread.h" using namespace std; using namespace libcamera; @@ -33,7 +33,7 @@ protected: int init() { - dispatcher = CameraManager::instance()->eventDispatcher(); + dispatcher = Thread::current()->eventDispatcher(); struct sigaction sa = {}; sa.sa_handler = &sigAlarmHandler; diff --git a/test/event.cpp b/test/event.cpp index 9bd87615..816060cc 100644 --- a/test/event.cpp +++ b/test/event.cpp @@ -9,12 +9,12 @@ #include <string.h> #include <unistd.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/event_notifier.h> #include <libcamera/timer.h> #include "test.h" +#include "thread.h" using namespace std; using namespace libcamera; @@ -35,7 +35,7 @@ protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); std::string data("H2G2"); Timer timeout; ssize_t ret; diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index 40a3a84a..f53042b8 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -15,12 +15,12 @@ #include <sys/wait.h> #include <unistd.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "ipc_unixsocket.h" #include "test.h" +#include "thread.h" #include "utils.h" #define CMD_CLOSE 0 @@ -47,7 +47,7 @@ public: UnixSocketTestSlave() : exitCode_(EXIT_FAILURE), exit_(false) { - dispatcher_ = CameraManager::instance()->eventDispatcher(); + dispatcher_ = Thread::current()->eventDispatcher(); ipc_.readyRead.connect(this, &UnixSocketTestSlave::readyRead); } @@ -436,7 +436,7 @@ private: return -ETIMEDOUT; } - CameraManager::instance()->eventDispatcher()->processEvents(); + Thread::current()->eventDispatcher()->processEvents(); } callResponse_ = nullptr; diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp index 36d25b27..2df4aa43 100644 --- a/test/log/log_process.cpp +++ b/test/log/log_process.cpp @@ -14,7 +14,6 @@ #include <unistd.h> #include <vector> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/logging.h> #include <libcamera/timer.h> @@ -22,6 +21,7 @@ #include "log.h" #include "process.h" #include "test.h" +#include "thread.h" #include "utils.h" using namespace std; @@ -65,7 +65,7 @@ protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int exitCode = 42; diff --git a/test/meson.build b/test/meson.build index 05265b7d..84722cce 100644 --- a/test/meson.build +++ b/test/meson.build @@ -13,22 +13,22 @@ subdir('v4l2_subdevice') subdir('v4l2_videodevice') public_tests = [ - ['event', 'event.cpp'], - ['event-dispatcher', 'event-dispatcher.cpp'], ['geometry', 'geometry.cpp'], ['list-cameras', 'list-cameras.cpp'], ['signal', 'signal.cpp'], - ['timer', 'timer.cpp'], ] internal_tests = [ ['camera-sensor', 'camera-sensor.cpp'], + ['event', 'event.cpp'], + ['event-dispatcher', 'event-dispatcher.cpp'], ['event-thread', 'event-thread.cpp'], ['message', 'message.cpp'], ['object', 'object.cpp'], ['object-invoke', 'object-invoke.cpp'], ['signal-threads', 'signal-threads.cpp'], ['threads', 'threads.cpp'], + ['timer', 'timer.cpp'], ['timer-thread', 'timer-thread.cpp'], ] diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp index 7221930f..37a27440 100644 --- a/test/object-invoke.cpp +++ b/test/object-invoke.cpp @@ -9,12 +9,11 @@ #include <iostream> #include <thread> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/object.h> -#include "thread.h" #include "test.h" +#include "thread.h" using namespace std; using namespace libcamera; @@ -61,7 +60,7 @@ class ObjectInvokeTest : public Test protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); InvokedObject object; /* diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index acb16145..d264555e 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -9,12 +9,12 @@ #include <unistd.h> #include <vector> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "process.h" #include "test.h" +#include "thread.h" #include "utils.h" using namespace std; @@ -41,7 +41,7 @@ public: protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int exitCode = 42; diff --git a/test/timer.cpp b/test/timer.cpp index addebce3..c30709d4 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -7,11 +7,11 @@ #include <iostream> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "test.h" +#include "thread.h" using namespace std; using namespace libcamera; @@ -62,7 +62,7 @@ protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); ManagedTimer timer; ManagedTimer timer2; diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp index 12ec88f2..1629f34c 100644 --- a/test/v4l2_videodevice/buffer_sharing.cpp +++ b/test/v4l2_videodevice/buffer_sharing.cpp @@ -13,10 +13,10 @@ #include <iostream> #include <libcamera/buffer.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> +#include "thread.h" #include "v4l2_videodevice_test.h" class BufferSharingTest : public V4L2VideoDeviceTest @@ -116,7 +116,7 @@ protected: int run() { - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int ret; diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp index 4909f71a..17eb528b 100644 --- a/test/v4l2_videodevice/capture_async.cpp +++ b/test/v4l2_videodevice/capture_async.cpp @@ -6,12 +6,12 @@ */ #include <libcamera/buffer.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include <iostream> +#include "thread.h" #include "v4l2_videodevice_test.h" class CaptureAsyncTest : public V4L2VideoDeviceTest @@ -34,7 +34,7 @@ protected: { const unsigned int bufferCount = 8; - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int ret; diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp index d132b1db..4d3644c2 100644 --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp @@ -8,12 +8,12 @@ #include <iostream> #include <libcamera/buffer.h> -#include <libcamera/camera_manager.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "device_enumerator.h" #include "media_device.h" +#include "thread.h" #include "v4l2_videodevice.h" #include "test.h" @@ -80,7 +80,7 @@ protected: { constexpr unsigned int bufferCount = 4; - EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher(); + EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); int ret; MediaEntity *entity = media_->getEntityByName("vim2m-source"); |