From patchwork Sat Aug 17 15:20:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1828 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D60B61934 for ; Sat, 17 Aug 2019 17:21:16 +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 3001EE70 for ; Sat, 17 Aug 2019 17:21:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566055276; bh=OY7Dg/cipX23bifMjwzzKjJ3eoAUe6GCfiF8dmYW5+s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FpkCJLnxPONWinLC9v8hbz7TGebpS/Rt1vS0cKBnkVpD95uZyCYLFgUzMpcYt1aUq QAjXcXYzprJ6YWr/dZtsyqi6C5eB7ghWGiM5nAAGNliTwZW861KpCGmOsx9XkUrSgA uPv6ziDFnHq25i602aVIqHdbhm9yWYCDWtlfrw/0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 17 Aug 2019 18:20:56 +0300 Message-Id: <20190817152104.10834-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190817152104.10834-1-laurent.pinchart@ideasonboard.com> References: <20190817152104.10834-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/18] libcamera: camera_manager: Bind CameraManager to threads 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: Sat, 17 Aug 2019 15:21:17 -0000 The CameraManager class uses the event dispatcher of the current thread. This makes the CameraManager::eventDispatcher() and CameraManager::setEventDispatcher() methods inconsistent, as they access different event dispatcher instances depending on the calling thread. Fix this by inheriting from the Object class, which binds the CameraManager to a thread, and use the event dispatcher of the bound thread. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/camera_manager.h | 4 +++- src/libcamera/camera_manager.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 0e8881baba40..ff7d4c7c6745 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -11,6 +11,8 @@ #include #include +#include + namespace libcamera { class Camera; @@ -18,7 +20,7 @@ class DeviceEnumerator; class EventDispatcher; class PipelineHandler; -class CameraManager +class CameraManager : public Object { public: int start(); diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 2cf014233b05..4a880684c5cb 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -248,7 +248,7 @@ CameraManager *CameraManager::instance() */ void CameraManager::setEventDispatcher(std::unique_ptr dispatcher) { - Thread::current()->setEventDispatcher(std::move(dispatcher)); + thread()->setEventDispatcher(std::move(dispatcher)); } /** @@ -264,7 +264,7 @@ void CameraManager::setEventDispatcher(std::unique_ptr dispatch */ EventDispatcher *CameraManager::eventDispatcher() { - return Thread::current()->eventDispatcher(); + return thread()->eventDispatcher(); } } /* namespace libcamera */