{"id":1844,"url":"https://patchwork.libcamera.org/api/1.1/patches/1844/?format=json","web_url":"https://patchwork.libcamera.org/patch/1844/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190818011329.14499-8-laurent.pinchart@ideasonboard.com>","date":"2019-08-18T01:13:22","name":"[libcamera-devel,07/14] test: Get event dispatcher from current thread","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"cf5fd310435f7326da6ad5bd303b0b3a11ed6b36","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1844/mbox/","series":[{"id":464,"url":"https://patchwork.libcamera.org/api/1.1/series/464/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=464","date":"2019-08-18T01:13:15","name":"Assorted fixes for Android camera HAL","version":1,"mbox":"https://patchwork.libcamera.org/series/464/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1844/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1844/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D8A161923\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 18 Aug 2019 03:13:43 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7ABE251C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 18 Aug 2019 03:13:42 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1566090822;\n\tbh=NmWlxoS6nKWRc6n3yGCqBZ1zLdgwbLjHHdiIv8Oh2fk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=wGpbrxiLEAgA7paYvgfca+T2dD9VxFwc3ESQ3IOAWs7Ip3sw4MYGBXMLHxCzqeSQR\n\tkpTgR5S0/iSiMBjcc1Orq39rzY+q0aev+j3f1s3KHw/xApn7PQWrcM8KRjdLpWwIvj\n\tz1s+fcM7sRGTja7NtyrgAXcR1Bu2r9z57eVHLYZA=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 07/14] test: Get event dispatcher from\n\tcurrent thread","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 18 Aug 2019 01:13:43 -0000"},"content":"For all tests that don't otherwise require access to the camera manager,\nget the event dispatcher from the current thread instead of the camera\nmanager. This prepares for the removal of CameraManager::instance().\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/event-dispatcher.cpp                | 4 ++--\n test/event.cpp                           | 4 ++--\n test/ipc/unixsocket.cpp                  | 6 +++---\n test/log/log_process.cpp                 | 4 ++--\n test/meson.build                         | 6 +++---\n test/object-invoke.cpp                   | 3 +--\n test/process/process_test.cpp            | 4 ++--\n test/timer.cpp                           | 4 ++--\n test/v4l2_videodevice/buffer_sharing.cpp | 4 ++--\n test/v4l2_videodevice/capture_async.cpp  | 4 ++--\n test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 ++--\n 11 files changed, 23 insertions(+), 24 deletions(-)","diff":"diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp\nindex e8818dcab4ad..f243ec39bc28 100644\n--- a/test/event-dispatcher.cpp\n+++ b/test/event-dispatcher.cpp\n@@ -9,11 +9,11 @@\n #include <signal.h>\n #include <sys/time.h>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"test.h\"\n+#include \"thread.h\"\n \n using namespace std;\n using namespace libcamera;\n@@ -33,7 +33,7 @@ protected:\n \n \tint init()\n \t{\n-\t\tdispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tdispatcher = Thread::current()->eventDispatcher();\n \n \t\tstruct sigaction sa = {};\n \t\tsa.sa_handler = &sigAlarmHandler;\ndiff --git a/test/event.cpp b/test/event.cpp\nindex 9bd876153a18..816060cc44a2 100644\n--- a/test/event.cpp\n+++ b/test/event.cpp\n@@ -9,12 +9,12 @@\n #include <string.h>\n #include <unistd.h>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/event_notifier.h>\n #include <libcamera/timer.h>\n \n #include \"test.h\"\n+#include \"thread.h\"\n \n using namespace std;\n using namespace libcamera;\n@@ -35,7 +35,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tstd::string data(\"H2G2\");\n \t\tTimer timeout;\n \t\tssize_t ret;\ndiff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\nindex 40a3a84a87d2..f53042b88720 100644\n--- a/test/ipc/unixsocket.cpp\n+++ b/test/ipc/unixsocket.cpp\n@@ -15,12 +15,12 @@\n #include <sys/wait.h>\n #include <unistd.h>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"ipc_unixsocket.h\"\n #include \"test.h\"\n+#include \"thread.h\"\n #include \"utils.h\"\n \n #define CMD_CLOSE\t0\n@@ -47,7 +47,7 @@ public:\n \tUnixSocketTestSlave()\n \t\t: exitCode_(EXIT_FAILURE), exit_(false)\n \t{\n-\t\tdispatcher_ = CameraManager::instance()->eventDispatcher();\n+\t\tdispatcher_ = Thread::current()->eventDispatcher();\n \t\tipc_.readyRead.connect(this, &UnixSocketTestSlave::readyRead);\n \t}\n \n@@ -436,7 +436,7 @@ private:\n \t\t\t\treturn -ETIMEDOUT;\n \t\t\t}\n \n-\t\t\tCameraManager::instance()->eventDispatcher()->processEvents();\n+\t\t\tThread::current()->eventDispatcher()->processEvents();\n \t\t}\n \n \t\tcallResponse_ = nullptr;\ndiff --git a/test/log/log_process.cpp b/test/log/log_process.cpp\nindex 36d25b27bfea..2df4aa43713c 100644\n--- a/test/log/log_process.cpp\n+++ b/test/log/log_process.cpp\n@@ -14,7 +14,6 @@\n #include <unistd.h>\n #include <vector>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/logging.h>\n #include <libcamera/timer.h>\n@@ -22,6 +21,7 @@\n #include \"log.h\"\n #include \"process.h\"\n #include \"test.h\"\n+#include \"thread.h\"\n #include \"utils.h\"\n \n using namespace std;\n@@ -65,7 +65,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tTimer timeout;\n \n \t\tint exitCode = 42;\ndiff --git a/test/meson.build b/test/meson.build\nindex 05265b7d4976..84722cceb35d 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -13,22 +13,22 @@ subdir('v4l2_subdevice')\n subdir('v4l2_videodevice')\n \n public_tests = [\n-    ['event',                           'event.cpp'],\n-    ['event-dispatcher',                'event-dispatcher.cpp'],\n     ['geometry',                        'geometry.cpp'],\n     ['list-cameras',                    'list-cameras.cpp'],\n     ['signal',                          'signal.cpp'],\n-    ['timer',                           'timer.cpp'],\n ]\n \n internal_tests = [\n     ['camera-sensor',                   'camera-sensor.cpp'],\n+    ['event',                           'event.cpp'],\n+    ['event-dispatcher',                'event-dispatcher.cpp'],\n     ['event-thread',                    'event-thread.cpp'],\n     ['message',                         'message.cpp'],\n     ['object',                          'object.cpp'],\n     ['object-invoke',                   'object-invoke.cpp'],\n     ['signal-threads',                  'signal-threads.cpp'],\n     ['threads',                         'threads.cpp'],\n+    ['timer',                           'timer.cpp'],\n     ['timer-thread',                    'timer-thread.cpp'],\n ]\n \ndiff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex 7221930f4380..9fb93e140305 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -9,7 +9,6 @@\n #include <iostream>\n #include <thread>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/object.h>\n \n@@ -61,7 +60,7 @@ class ObjectInvokeTest : public Test\n protected:\n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tInvokedObject object;\n \n \t\t/*\ndiff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\nindex acb161454e2e..d264555e545f 100644\n--- a/test/process/process_test.cpp\n+++ b/test/process/process_test.cpp\n@@ -9,12 +9,12 @@\n #include <unistd.h>\n #include <vector>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"process.h\"\n #include \"test.h\"\n+#include \"thread.h\"\n #include \"utils.h\"\n \n using namespace std;\n@@ -41,7 +41,7 @@ public:\n protected:\n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tTimer timeout;\n \n \t\tint exitCode = 42;\ndiff --git a/test/timer.cpp b/test/timer.cpp\nindex addebce3c784..c30709d4109a 100644\n--- a/test/timer.cpp\n+++ b/test/timer.cpp\n@@ -7,11 +7,11 @@\n \n #include <iostream>\n \n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"test.h\"\n+#include \"thread.h\"\n \n using namespace std;\n using namespace libcamera;\n@@ -62,7 +62,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tManagedTimer timer;\n \t\tManagedTimer timer2;\n \ndiff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\nindex 12ec88f2d8e6..1629f34cfa6c 100644\n--- a/test/v4l2_videodevice/buffer_sharing.cpp\n+++ b/test/v4l2_videodevice/buffer_sharing.cpp\n@@ -13,10 +13,10 @@\n #include <iostream>\n \n #include <libcamera/buffer.h>\n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n+#include \"thread.h\"\n #include \"v4l2_videodevice_test.h\"\n \n class BufferSharingTest : public V4L2VideoDeviceTest\n@@ -116,7 +116,7 @@ protected:\n \n \tint run()\n \t{\n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tTimer timeout;\n \t\tint ret;\n \ndiff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\nindex 4909f71a3f34..17eb528b12fd 100644\n--- a/test/v4l2_videodevice/capture_async.cpp\n+++ b/test/v4l2_videodevice/capture_async.cpp\n@@ -6,12 +6,12 @@\n  */\n \n #include <libcamera/buffer.h>\n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include <iostream>\n \n+#include \"thread.h\"\n #include \"v4l2_videodevice_test.h\"\n \n class CaptureAsyncTest : public V4L2VideoDeviceTest\n@@ -34,7 +34,7 @@ protected:\n \t{\n \t\tconst unsigned int bufferCount = 8;\n \n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tTimer timeout;\n \t\tint ret;\n \ndiff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\nindex d132b1db2432..4d3644c2d287 100644\n--- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n+++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp\n@@ -8,12 +8,12 @@\n #include <iostream>\n \n #include <libcamera/buffer.h>\n-#include <libcamera/camera_manager.h>\n #include <libcamera/event_dispatcher.h>\n #include <libcamera/timer.h>\n \n #include \"device_enumerator.h\"\n #include \"media_device.h\"\n+#include \"thread.h\"\n #include \"v4l2_videodevice.h\"\n \n #include \"test.h\"\n@@ -80,7 +80,7 @@ protected:\n \t{\n \t\tconstexpr unsigned int bufferCount = 4;\n \n-\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n \t\tint ret;\n \n \t\tMediaEntity *entity = media_->getEntityByName(\"vim2m-source\");\n","prefixes":["libcamera-devel","07/14"]}