From fd0087b5d8608eb1dc1e1a3da5ddafd83d43fc79 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 18 Aug 2019 03:11:27 +0300 Subject: 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 Reviewed-by: Jacopo Mondi --- test/event-dispatcher.cpp | 4 ++-- test/event.cpp | 4 ++-- test/ipc/unixsocket.cpp | 6 +++--- test/log/log_process.cpp | 4 ++-- test/meson.build | 6 +++--- test/object-invoke.cpp | 5 ++--- test/process/process_test.cpp | 4 ++-- test/timer.cpp | 4 ++-- test/v4l2_videodevice/buffer_sharing.cpp | 4 ++-- test/v4l2_videodevice/capture_async.cpp | 4 ++-- test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 ++-- 11 files changed, 24 insertions(+), 25 deletions(-) (limited to 'test') 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 #include -#include #include #include #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 #include -#include #include #include #include #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 #include -#include #include #include #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 #include -#include #include #include #include @@ -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 #include -#include #include #include -#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 #include -#include #include #include #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 -#include #include #include #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 #include -#include #include #include +#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 -#include #include #include #include +#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 #include -#include #include #include #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"); -- cgit v1.2.1