From patchwork Sun Aug 18 01:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1844 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D8A161923 for ; Sun, 18 Aug 2019 03:13:43 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7ABE251C for ; Sun, 18 Aug 2019 03:13:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566090822; bh=NmWlxoS6nKWRc6n3yGCqBZ1zLdgwbLjHHdiIv8Oh2fk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wGpbrxiLEAgA7paYvgfca+T2dD9VxFwc3ESQ3IOAWs7Ip3sw4MYGBXMLHxCzqeSQR kpTgR5S0/iSiMBjcc1Orq39rzY+q0aev+j3f1s3KHw/xApn7PQWrcM8KRjdLpWwIvj z1s+fcM7sRGTja7NtyrgAXcR1Bu2r9z57eVHLYZA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 18 Aug 2019 04:13:22 +0300 Message-Id: <20190818011329.14499-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190818011329.14499-1-laurent.pinchart@ideasonboard.com> References: <20190818011329.14499-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/14] test: Get event dispatcher from current thread X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Aug 2019 01:13:43 -0000 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 | 3 +-- 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, 23 insertions(+), 24 deletions(-) diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp index e8818dcab4ad..f243ec39bc28 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 9bd876153a18..816060cc44a2 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 40a3a84a87d2..f53042b88720 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 36d25b27bfea..2df4aa43713c 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 05265b7d4976..84722cceb35d 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 7221930f4380..9fb93e140305 100644 --- a/test/object-invoke.cpp +++ b/test/object-invoke.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -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 acb161454e2e..d264555e545f 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 addebce3c784..c30709d4109a 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 12ec88f2d8e6..1629f34cfa6c 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 4909f71a3f34..17eb528b12fd 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 d132b1db2432..4d3644c2d287 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");