From patchwork Thu Oct 28 11:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 14397 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C47A6BF415 for ; Thu, 28 Oct 2021 11:14:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 503AB60253; Thu, 28 Oct 2021 13:14:42 +0200 (CEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27FBF600BA for ; Thu, 28 Oct 2021 13:14:38 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id B186DFF80E; Thu, 28 Oct 2021 11:14:37 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 13:15:12 +0200 Message-Id: <20211028111520.256612-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211028111520.256612-1-jacopo@jmondi.org> References: <20211028111520.256612-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/10] libcamera: event_notifier: Add 'enable' constructor parameter X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an 'enable' parameter to the EventNotifier class constructor. Currently an EvenNotifier is enabled as soon as it is constructed. Add an optional parameter to the class constructor to allow post-poning the notifier activation. As the 'enable' parameter has a default value of true, existing users of the class should not be updated. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- include/libcamera/base/event_notifier.h | 2 +- src/libcamera/base/event_notifier.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h index f7722a32ef55..4d373a5290cc 100644 --- a/include/libcamera/base/event_notifier.h +++ b/include/libcamera/base/event_notifier.h @@ -25,7 +25,7 @@ public: Exception, }; - EventNotifier(int fd, Type type, Object *parent = nullptr); + EventNotifier(int fd, Type type, Object *parent = nullptr, bool enable = true); virtual ~EventNotifier(); Type type() const { return type_; } diff --git a/src/libcamera/base/event_notifier.cpp b/src/libcamera/base/event_notifier.cpp index fd93c0878c6f..40428cf24a50 100644 --- a/src/libcamera/base/event_notifier.cpp +++ b/src/libcamera/base/event_notifier.cpp @@ -26,8 +26,11 @@ namespace libcamera { * * The EventNotifier models a file descriptor event source that can be * monitored. It is created with the file descriptor to be monitored and the - * type of event, and is enabled by default. It will emit the \ref activated - * signal whenever an event of the monitored type occurs on the file descriptor. + * type of event. It will emit the \ref activated signal whenever an event of + * the monitored type occurs on the file descriptor. + * + * An EventNotifier is enabled by default when created, unless otherwise + * specified through the optional 'enable' constructor parameter. * * Supported type of events are EventNotifier::Read, EventNotifier::Write and * EventNotifier::Exception. The type is specified when constructing the @@ -62,11 +65,12 @@ namespace libcamera { * \param[in] fd The file descriptor to monitor * \param[in] type The event type to monitor * \param[in] parent The parent Object + * \param[in] enable Notifier enable flag */ -EventNotifier::EventNotifier(int fd, Type type, Object *parent) +EventNotifier::EventNotifier(int fd, Type type, Object *parent, bool enable) : Object(parent), fd_(fd), type_(type), enabled_(false) { - setEnabled(true); + setEnabled(enable); } EventNotifier::~EventNotifier()