From patchwork Fri Aug 27 02:38:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13522 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 1A795BD87D for ; Fri, 27 Aug 2021 02:38:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 90BB168920; Fri, 27 Aug 2021 04:38:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oEtzj+be"; dkim-atps=neutral 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 56C4368920 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DADF9739 for ; Fri, 27 Aug 2021 04:38:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031926; bh=A78D8AItOpk0oS9bj5WE47DSTohUsopQK6EwoK7txjU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oEtzj+beX3W5b5VMeLp4zT/y1Y0YRftGOjvuhUxyTwybfBkeyHJS54zzBObDG5fBM BMJ/YEXKYt9oupBHFzVN7HNTO0HXaPlmwzr6NIpPpGP8VyhHC/EV4ezJHKtuWDlGqX xNYdvdS0Y20X4Du4Jm4ZCF+nrECdRie93aAUS4Sk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:24 +0300 Message-Id: <20210827023829.5871-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/6] libcamera: Use simpler Signal::disconnect() function 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" When disconnecting a signal from a receiver, it is usually not necessary to specify the receiver's slot function explicitly, as the signal is often connected to a single slot for a given receiver. We can thus use a simpler version of Signal::disconnect() that takes a pointer to the receiver object only. This reduces code size, as the disconnect() function is a template function. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/lc-compliance/simple_capture.cpp | 2 +- src/libcamera/camera_manager.cpp | 2 +- src/qcam/main_window.cpp | 4 ++-- test/camera/camera_reconfigure.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp index 25097f28a603..ab5cb35c11f2 100644 --- a/src/lc-compliance/simple_capture.cpp +++ b/src/lc-compliance/simple_capture.cpp @@ -62,7 +62,7 @@ void SimpleCapture::stop() camera_->stop(); - camera_->requestCompleted.disconnect(this, &SimpleCapture::requestComplete); + camera_->requestCompleted.disconnect(this); Stream *stream = config_->at(0).stream(); allocator_->free(stream); diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index fe80a46f5d20..08457030b6f7 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -170,7 +170,7 @@ void CameraManager::Private::createPipelineHandlers() void CameraManager::Private::cleanup() { - enumerator_->devicesAdded.disconnect(this, &Private::createPipelineHandlers); + enumerator_->devicesAdded.disconnect(this); /* * Release all references to cameras to ensure they all get destroyed diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 1adaae60d83b..dea81bb43774 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -531,7 +531,7 @@ int MainWindow::startCapture() return 0; error_disconnect: - camera_->requestCompleted.disconnect(this, &MainWindow::requestComplete); + camera_->requestCompleted.disconnect(this); camera_->stop(); error: @@ -571,7 +571,7 @@ void MainWindow::stopCapture() if (ret) qInfo() << "Failed to stop capture"; - camera_->requestCompleted.disconnect(this, &MainWindow::requestComplete); + camera_->requestCompleted.disconnect(this); for (auto &iter : mappedBuffers_) { const Span &buffer = iter.second; diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp index 5adef16e1c9e..48d61c00709c 100644 --- a/test/camera/camera_reconfigure.cpp +++ b/test/camera/camera_reconfigure.cpp @@ -130,7 +130,7 @@ private: return TestFail; } - camera_->requestCompleted.disconnect(this, &CameraReconfigure::requestComplete); + camera_->requestCompleted.disconnect(this); requests_.clear(); From patchwork Fri Aug 27 02:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13523 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 2DC54C3241 for ; Fri, 27 Aug 2021 02:38:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B92BD6894A; Fri, 27 Aug 2021 04:38:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ljlryFUz"; dkim-atps=neutral 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 9518B68932 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 34E4FBB0 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031926; bh=X2IyT8bRk8g/GguloMinx4pjAVyKjtFSpK3MPSOqeI8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ljlryFUzhXHfR+cWUbphYYnUFjiS4rye4brVxXiWE0KBysnjLd7ftkbU/IImBNpvF TMdjRFF3CB3hjN3qFKblgPtkFI8miRAmeaTDQq605w0RCbbzZNpoqjq7E5QleUg1dD j29vpppPlFIJxs4Sdwac8N8pB0xyjj0tkCSrYWk4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:25 +0300 Message-Id: <20210827023829.5871-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/6] libcamera: base: bound_method: Remove BoundMethodMember specialization 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" The BoundMethodMember specialization for the void return type is only needed to avoid accessing the ret_ member variable that is lacking from the corresponding BoundMethodPack specialization. By adding a BoundMethodPack::returnValue() function to read the member variable, we can remove the complete BoundMethodMember specialization. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/bound_method.h | 46 ++++++--------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 282f9b58ab60..9c212f1ecc3a 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -38,6 +38,11 @@ public: { } + R returnValue() + { + return ret_; + } + std::tuple...> args_; R ret_; }; @@ -51,6 +56,10 @@ public: { } + void returnValue() + { + } + std::tuple...> args_; }; @@ -160,7 +169,7 @@ public: auto pack = std::make_shared(args...); bool sync = BoundMethodBase::activatePack(pack, deleteMethod); - return sync ? pack->ret_ : R(); + return sync ? pack->returnValue() : R(); } R invoke(Args... args) override @@ -173,41 +182,6 @@ private: R (T::*func_)(Args...); }; -template -class BoundMethodMember : public BoundMethodArgs -{ -public: - using PackType = typename BoundMethodArgs::PackType; - - BoundMethodMember(T *obj, Object *object, void (T::*func)(Args...), - ConnectionType type = ConnectionTypeAuto) - : BoundMethodArgs(obj, object, type), func_(func) - { - } - - bool match(void (T::*func)(Args...)) const { return func == func_; } - - void activate(Args... args, bool deleteMethod = false) override - { - if (!this->object_) { - T *obj = static_cast(this->obj_); - return (obj->*func_)(args...); - } - - auto pack = std::make_shared(args...); - BoundMethodBase::activatePack(pack, deleteMethod); - } - - void invoke(Args... args) override - { - T *obj = static_cast(this->obj_); - return (obj->*func_)(args...); - } - -private: - void (T::*func_)(Args...); -}; - template class BoundMethodStatic : public BoundMethodArgs { From patchwork Fri Aug 27 02:38:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13524 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 ADDA8C3242 for ; Fri, 27 Aug 2021 02:38:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56CE86894D; Fri, 27 Aug 2021 04:38:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Dq7xO4El"; dkim-atps=neutral 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 DE3B968932 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 820795A1 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031926; bh=/CT9LXBbuiJs722tlb64o45gG2f7PBV52Oe+OkIU0Tk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Dq7xO4ElalIJoTnFQqDg1XfiYBDdoPSAhRWbyu06qTU9+ocMBzhEJoyPgJ2NWfboR jCESsTh7SWBoNTiKslWAhUHViYt4SZvDfUPkq/5TQLM0qf79ArE/fw2ZBXzehrZ60D RINDkZ+rc314itXEM/bgETFS+8s0NQrPQxOO1EmY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:26 +0300 Message-Id: <20210827023829.5871-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/6] libcamera: base: bound_method: Remove BoundMethodArgs specialization 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" The BoundMethodArgs specialization for the void return type is only needed to avoid accessing the ret_ member variable that is lacking from the corresponding BoundMethodPack specialization. As the member variable is only accessed in a single function, instead of specializing the whole class we can use SFINAE to select between two different implementations of the function. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/bound_method.h | 34 +++++++-------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 9c212f1ecc3a..76ce8017e721 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -98,35 +98,17 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, std::index_sequence) + template + std::enable_if_t::value, void> + invokePack(BoundMethodPackBase *pack, std::index_sequence) { PackType *args = static_cast(pack); args->ret_ = invoke(std::get(args->args_)...); } -public: - BoundMethodArgs(void *obj, Object *object, ConnectionType type) - : BoundMethodBase(obj, object, type) {} - - void invokePack(BoundMethodPackBase *pack) override - { - invokePack(pack, std::make_index_sequence{}); - } - - virtual R activate(Args... args, bool deleteMethod = false) = 0; - virtual R invoke(Args... args) = 0; -}; - -template -class BoundMethodArgs : public BoundMethodBase -{ -public: - using PackType = BoundMethodPack; - -private: - template - void invokePack(BoundMethodPackBase *pack, std::index_sequence) + template + std::enable_if_t::value, void> + invokePack(BoundMethodPackBase *pack, std::index_sequence) { /* args is effectively unused when the sequence I is empty. */ PackType *args [[gnu::unused]] = static_cast(pack); @@ -142,8 +124,8 @@ public: invokePack(pack, std::make_index_sequence{}); } - virtual void activate(Args... args, bool deleteMethod = false) = 0; - virtual void invoke(Args... args) = 0; + virtual R activate(Args... args, bool deleteMethod = false) = 0; + virtual R invoke(Args... args) = 0; }; template From patchwork Fri Aug 27 02:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13525 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 48D3FBD87D for ; Fri, 27 Aug 2021 02:38:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E0DED68928; Fri, 27 Aug 2021 04:38:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="quB1niBk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3852268932 for ; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D09B8739 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031927; bh=cs4NVSKpxfneJ2591N2rLe10LLTCB1h3oRmVFwa8SjM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=quB1niBkCj2TxxANOpxwtnTO/q0tBJxllYyMpnsadlLtsZ5+Jr03F+JPzNuT0PJKu gLrW5E9u7j5CnPDeSMwwIRNK3o5W+GjYScYZhlY+4DDgr7DDBvbFHXE9bOS6Pfy8oZ ZNEZDXl24mwCaMrlH3p9iKXYWfkSaO9mmC02DJMM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:27 +0300 Message-Id: <20210827023829.5871-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/6] libcamera: base: signal: Support connecting signals to functors 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" It can be useful to connect a signal to a functor, and in particular a lambda function, while still operating in the context of a receiver object (to support both object-based disconnection and queued connections to Object instances). Add a BoundMethodFunctor class to bind a functor, and a corresponding Signal::connect() function. There is no corresponding disconnect() function, as a lambda passed to connect() can't be later passed to disconnect(). Disconnection typically uses disconnect(T *object), which will cover the vast majority of use cases. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- Documentation/Doxyfile.in | 1 + include/libcamera/base/bound_method.h | 31 +++++++++++++++++++++ include/libcamera/base/signal.h | 19 +++++++++++++ src/libcamera/base/signal.cpp | 24 +++++++++++++++++ test/signal.cpp | 39 +++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index dc03cbea4b02..d562510e902e 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -878,6 +878,7 @@ EXCLUDE_PATTERNS = @TOP_BUILDDIR@/include/libcamera/ipa/*_serializer.h \ EXCLUDE_SYMBOLS = libcamera::BoundMethodArgs \ libcamera::BoundMethodBase \ + libcamera::BoundMethodFunctor \ libcamera::BoundMethodMember \ libcamera::BoundMethodPack \ libcamera::BoundMethodPackBase \ diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 76ce8017e721..ebd297ab8209 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -128,6 +128,37 @@ public: virtual R invoke(Args... args) = 0; }; +template +class BoundMethodFunctor : public BoundMethodArgs +{ +public: + using PackType = typename BoundMethodArgs::PackType; + + BoundMethodFunctor(T *obj, Object *object, Func func, + ConnectionType type = ConnectionTypeAuto) + : BoundMethodArgs(obj, object, type), func_(func) + { + } + + R activate(Args... args, bool deleteMethod = false) override + { + if (!this->object_) + return func_(args...); + + auto pack = std::make_shared(args...); + bool sync = BoundMethodBase::activatePack(pack, deleteMethod); + return sync ? pack->returnValue() : R(); + } + + R invoke(Args... args) override + { + return func_(args...); + } + +private: + Func func_; +}; + template class BoundMethodMember : public BoundMethodArgs { diff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h index c2521769a843..8d9f82f62d0d 100644 --- a/include/libcamera/base/signal.h +++ b/include/libcamera/base/signal.h @@ -61,6 +61,25 @@ public: SignalBase::connect(new BoundMethodMember(obj, nullptr, func)); } +#ifndef __DOXYGEN__ + template::value> * = nullptr> + void connect(T *obj, Func func, ConnectionType type = ConnectionTypeAuto) + { + Object *object = static_cast(obj); + SignalBase::connect(new BoundMethodFunctor(obj, object, func, type)); + } + + template::value> * = nullptr> +#else + template +#endif + void connect(T *obj, Func func) + { + SignalBase::connect(new BoundMethodFunctor(obj, nullptr, func)); + } + template void connect(R (*func)(Args...)) { diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp index adcfa796870e..9c2319c59106 100644 --- a/src/libcamera/base/signal.cpp +++ b/src/libcamera/base/signal.cpp @@ -121,6 +121,30 @@ SignalBase::SlotList SignalBase::slots() * \context This function is \threadsafe. */ +/** + * \fn Signal::connect(T *object, Func func) + * \brief Connect the signal to a function object slot + * \param[in] object The slot object pointer + * \param[in] func The function object + * + * If the typename T inherits from Object, the signal will be automatically + * disconnected from the \a func slot of \a object when \a object is destroyed. + * Otherwise the caller shall disconnect signals manually before destroying \a + * object. + * + * The function object is typically a lambda function, but may be any object + * that satisfies the FunctionObject named requirements. The types of the + * function object arguments shall match the types of the signal arguments. + * + * No matching disconnect() function exist, as it wouldn't be possible to pass + * to a disconnect() function the same lambda that was passed to connect(). The + * connection created by this function can not be removed selectively if the + * signal is connected to multiple slots of the same receiver, but may be + * otherwise be removed using the disconnect(T *object) function. + * + * \context This function is \threadsafe. + */ + /** * \fn Signal::connect(R (*func)(Args...)) * \brief Connect the signal to a static function slot diff --git a/test/signal.cpp b/test/signal.cpp index 595782a2cd6e..fcf2def18df4 100644 --- a/test/signal.cpp +++ b/test/signal.cpp @@ -191,6 +191,24 @@ protected: signalVoid_.connect(slotStaticReturn); signalVoid_.connect(this, &SignalTest::slotReturn); + /* Test signal connection to a lambda. */ + int value = 0; + signalInt_.connect(this, [&](int v) { value = v; }); + signalInt_.emit(42); + + if (value != 42) { + cout << "Signal connection to lambda failed" << endl; + return TestFail; + } + + signalInt_.disconnect(this); + signalInt_.emit(0); + + if (value != 42) { + cout << "Signal disconnection from lambda failed" << endl; + return TestFail; + } + /* ----------------- Signal -> Object tests ----------------- */ /* @@ -256,6 +274,27 @@ protected: delete slotObject; + /* Test signal connection to a lambda. */ + slotObject = new SlotObject(); + value = 0; + signalInt_.connect(slotObject, [&](int v) { value = v; }); + signalInt_.emit(42); + + if (value != 42) { + cout << "Signal connection to Object lambda failed" << endl; + return TestFail; + } + + signalInt_.disconnect(slotObject); + signalInt_.emit(0); + + if (value != 42) { + cout << "Signal disconnection from Object lambda failed" << endl; + return TestFail; + } + + delete slotObject; + /* --------- Signal -> Object (multiple inheritance) -------- */ /* From patchwork Fri Aug 27 02:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13526 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 ED46FC3243 for ; Fri, 27 Aug 2021 02:38:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78F7168951; Fri, 27 Aug 2021 04:38:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="suyYIUIW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EDE868932 for ; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2AA9A5A1 for ; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031927; bh=Tp3dZB2PAoqMJo/t/PeTR6CadAqCDOBgLYqygLaTGhA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=suyYIUIWsCBpn4kf1bUB785neLCZYuHKahV8EY2ro5TDqNt/6pFQH/kdekzsOclQ4 /FDKsqc8lecVhd2xVG2Rg6Z9PDoiVt2aTYOFWCpKE6XbDxVZudwYITilSlQ5/yXWTn 3wuv/cg7oKH20Cgjs3M/8Nvoj6M+RWpGZ8JDH2os= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:28 +0300 Message-Id: <20210827023829.5871-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/6] libcamera: Don't use emitter object pointer argument to slot 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" In many cases, the emitter object passed as a pointer from signals to slots is also available as a class member. Use the class member when this occurs, to prepare for removal of the emitter object pointer from signals. In test/event.cpp, this additionally requires moving the EventNotifier to a class member. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/libcamera/ipc_pipe_unixsocket.cpp | 4 ++-- test/event-thread.cpp | 4 ++-- test/event.cpp | 17 +++++++++++------ test/ipa/ipa_interface_test.cpp | 4 ++-- test/ipc/unixsocket.cpp | 8 ++++---- test/ipc/unixsocket_ipc.cpp | 4 ++-- .../module_ipa_proxy_worker.cpp.tmpl | 4 ++-- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp index 4511775fb467..38bcc30a21ed 100644 --- a/src/libcamera/ipc_pipe_unixsocket.cpp +++ b/src/libcamera/ipc_pipe_unixsocket.cpp @@ -82,10 +82,10 @@ int IPCPipeUnixSocket::sendAsync(const IPCMessage &data) return 0; } -void IPCPipeUnixSocket::readyRead(IPCUnixSocket *socket) +void IPCPipeUnixSocket::readyRead([[maybe_unused]] IPCUnixSocket *socket) { IPCUnixSocket::Payload payload; - int ret = socket->receive(&payload); + int ret = socket_->receive(&payload); if (ret) { LOG(IPCPipe, Error) << "Receive message failed" << ret; return; diff --git a/test/event-thread.cpp b/test/event-thread.cpp index 575261664c2f..12021710ef41 100644 --- a/test/event-thread.cpp +++ b/test/event-thread.cpp @@ -66,9 +66,9 @@ public: } private: - void readReady(EventNotifier *notifier) + void readReady([[maybe_unused]] EventNotifier *notifier) { - size_ = read(notifier->fd(), data_, sizeof(data_)); + size_ = read(notifier_->fd(), data_, sizeof(data_)); notified_ = true; } diff --git a/test/event.cpp b/test/event.cpp index c2274344b7f0..e338335c11e8 100644 --- a/test/event.cpp +++ b/test/event.cpp @@ -22,14 +22,16 @@ using namespace libcamera; class EventTest : public Test { protected: - void readReady(EventNotifier *notifier) + void readReady([[maybe_unused]] EventNotifier *notifier) { - size_ = read(notifier->fd(), data_, sizeof(data_)); + size_ = read(notifier_->fd(), data_, sizeof(data_)); notified_ = true; } int init() { + notifier_ = nullptr; + return pipe(pipefd_); } @@ -40,8 +42,8 @@ protected: Timer timeout; ssize_t ret; - EventNotifier readNotifier(pipefd_[0], EventNotifier::Read); - readNotifier.activated.connect(this, &EventTest::readReady); + notifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read); + notifier_->activated.connect(this, &EventTest::readReady); /* Test read notification with data. */ memset(data_, 0, sizeof(data_)); @@ -76,7 +78,7 @@ protected: /* Test read notifier disabling. */ notified_ = false; - readNotifier.setEnabled(false); + notifier_->setEnabled(false); ret = write(pipefd_[1], data.data(), data.size()); if (ret < 0) { @@ -95,7 +97,7 @@ protected: /* Test read notifier enabling. */ notified_ = false; - readNotifier.setEnabled(true); + notifier_->setEnabled(true); timeout.start(100); dispatcher->processEvents(); @@ -111,6 +113,8 @@ protected: void cleanup() { + delete notifier_; + close(pipefd_[0]); close(pipefd_[1]); } @@ -118,6 +122,7 @@ protected: private: int pipefd_[2]; + EventNotifier *notifier_; bool notified_; char data_[16]; ssize_t size_; diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index ee9f26510784..0ee51f71fd87 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -153,9 +153,9 @@ protected: } private: - void readTrace(EventNotifier *notifier) + void readTrace([[maybe_unused]] EventNotifier *notifier) { - ssize_t s = read(notifier->fd(), &trace_, sizeof(trace_)); + ssize_t s = read(notifier_->fd(), &trace_, sizeof(trace_)); if (s < 0) { int ret = errno; cerr << "Failed to read from IPA test FIFO at '" diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index aa35c8f071f1..6507fb12d74b 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -68,12 +68,12 @@ public: } private: - void readyRead(IPCUnixSocket *ipc) + void readyRead([[maybe_unused]] IPCUnixSocket *ipc) { IPCUnixSocket::Payload message, response; int ret; - ret = ipc->receive(&message); + ret = ipc_.receive(&message); if (ret) { cerr << "Receive message failed: " << ret << endl; return; @@ -447,14 +447,14 @@ private: return 0; } - void readyRead(IPCUnixSocket *ipc) + void readyRead([[maybe_unused]] IPCUnixSocket *ipc) { if (!callResponse_) { cerr << "Read ready without expecting data, fail." << endl; return; } - if (ipc->receive(callResponse_)) { + if (ipc_.receive(callResponse_)) { cerr << "Receive message failed" << endl; return; } diff --git a/test/ipc/unixsocket_ipc.cpp b/test/ipc/unixsocket_ipc.cpp index 6fe7fd9b8fc5..60317a4956b8 100644 --- a/test/ipc/unixsocket_ipc.cpp +++ b/test/ipc/unixsocket_ipc.cpp @@ -65,12 +65,12 @@ public: } private: - void readyRead(IPCUnixSocket *ipc) + void readyRead([[maybe_unused]] IPCUnixSocket *ipc) { IPCUnixSocket::Payload message; int ret; - ret = ipc->receive(&message); + ret = ipc_.receive(&message); if (ret) { cerr << "Receive message failed: " << ret << endl; return; diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl index 8a88bd467da7..b4cd1aa9e823 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl @@ -57,10 +57,10 @@ public: ~{{proxy_worker_name}}() {} - void readyRead(IPCUnixSocket *socket) + void readyRead([[maybe_unused]] IPCUnixSocket *socket) { IPCUnixSocket::Payload _message; - int _retRecv = socket->receive(&_message); + int _retRecv = socket_.receive(&_message); if (_retRecv) { LOG({{proxy_worker_name}}, Error) << "Receive message failed: " << _retRecv; From patchwork Fri Aug 27 02:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13527 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 7CCF3C3244 for ; Fri, 27 Aug 2021 02:38:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 129B868934; Fri, 27 Aug 2021 04:38:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NzZIll0J"; dkim-atps=neutral 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 D7E7668941 for ; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 79B52739 for ; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031927; bh=bCidoeArIRkF+sAqpdQ38lZWGfG6D64C0nT3/tj/8VQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NzZIll0JF7b0dYcaa2F8LtWleEAud7BlOivStJDvWMkKGrJP0KsL+VeWBTAOzQKBe /bDBh5GabDWeJZSR+pAyMNakGCn7IvnOm0Q1pd+WeKnV/eONzEcaioGGIwe4z25Bz9 Ohu0B411q2hlMzUmFDwZvQImiceegohtZKS/YqwQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:29 +0300 Message-Id: <20210827023829.5871-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/6] libcamera: Drop emitter object pointer from signal arguments 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" Many signals used in internal and public APIs carry the emitter pointer as a signal argument. This was done to allow slots connected to multiple signal instances to differentiate between emitters. While starting from a good intention of facilitating the implementation of slots, it turned out to be a bad API design as the signal isn't meant to know what it will be connected to, and thus shouldn't carry parameters that are solely meant to support a use case specific to the connected slot. These pointers turn out to be unused in all slots but one. In the only case where it is needed, it can be obtained by wrapping the slot in a lambda function when connecting the signal. Do so, and drop the emitter pointer from all signals. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/event_notifier.h | 2 +- include/libcamera/base/thread.h | 2 +- include/libcamera/base/timer.h | 2 +- include/libcamera/camera.h | 2 +- include/libcamera/internal/device_enumerator_udev.h | 2 +- include/libcamera/internal/ipc_pipe_unixsocket.h | 2 +- include/libcamera/internal/ipc_unixsocket.h | 4 ++-- include/libcamera/internal/media_device.h | 2 +- include/libcamera/internal/process.h | 4 ++-- include/libcamera/internal/v4l2_device.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/base/event_dispatcher_poll.cpp | 4 ++-- src/libcamera/base/thread.cpp | 2 +- src/libcamera/camera.cpp | 2 +- src/libcamera/device_enumerator.cpp | 2 +- src/libcamera/device_enumerator_udev.cpp | 2 +- src/libcamera/ipc_pipe_unixsocket.cpp | 2 +- src/libcamera/ipc_unixsocket.cpp | 4 ++-- src/libcamera/pipeline_handler.cpp | 2 +- src/libcamera/process.cpp | 4 ++-- src/libcamera/v4l2_device.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 3 +-- test/event-thread.cpp | 2 +- test/event.cpp | 2 +- test/ipa/ipa_interface_test.cpp | 2 +- test/ipc/unixsocket.cpp | 4 ++-- test/ipc/unixsocket_ipc.cpp | 2 +- test/log/log_process.cpp | 3 +-- test/process/process_test.cpp | 3 +-- test/timer-thread.cpp | 2 +- test/timer.cpp | 2 +- .../libcamera_templates/module_ipa_proxy_worker.cpp.tmpl | 2 +- 32 files changed, 38 insertions(+), 42 deletions(-) diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h index 5055ccbf21ca..f7722a32ef55 100644 --- a/include/libcamera/base/event_notifier.h +++ b/include/libcamera/base/event_notifier.h @@ -34,7 +34,7 @@ public: bool enabled() const { return enabled_; } void setEnabled(bool enable); - Signal activated; + Signal<> activated; protected: void message(Message *msg) override; diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h index 762beab2a360..e0ca0aeaa761 100644 --- a/include/libcamera/base/thread.h +++ b/include/libcamera/base/thread.h @@ -41,7 +41,7 @@ public: bool isRunning(); - Signal finished; + Signal<> finished; static Thread *current(); static pid_t currentId(); diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h index 798821611c6c..44876a85dc0a 100644 --- a/include/libcamera/base/timer.h +++ b/include/libcamera/base/timer.h @@ -33,7 +33,7 @@ public: std::chrono::steady_clock::time_point deadline() const { return deadline_; } - Signal timeout; + Signal<> timeout; protected: void message(Message *msg) override; diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 05cdab724b10..601ee46e415b 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -86,7 +86,7 @@ public: Signal bufferCompleted; Signal requestCompleted; - Signal disconnected; + Signal<> disconnected; int acquire(); int release(); diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h index 58e64a297b1d..c035298081b4 100644 --- a/include/libcamera/internal/device_enumerator_udev.h +++ b/include/libcamera/internal/device_enumerator_udev.h @@ -59,7 +59,7 @@ private: std::string lookupDeviceNode(dev_t devnum); int addV4L2Device(dev_t devnum); - void udevNotify(EventNotifier *notifier); + void udevNotify(); struct udev *udev_; struct udev_monitor *monitor_; diff --git a/include/libcamera/internal/ipc_pipe_unixsocket.h b/include/libcamera/internal/ipc_pipe_unixsocket.h index 4ffdddcc7f92..ad2927fed7f0 100644 --- a/include/libcamera/internal/ipc_pipe_unixsocket.h +++ b/include/libcamera/internal/ipc_pipe_unixsocket.h @@ -35,7 +35,7 @@ private: bool done; }; - void readyRead(IPCUnixSocket *socket); + void readyRead(); int call(const IPCUnixSocket::Payload &message, IPCUnixSocket::Payload *response, uint32_t seq); diff --git a/include/libcamera/internal/ipc_unixsocket.h b/include/libcamera/internal/ipc_unixsocket.h index 9f5b06773ced..2b87196c4851 100644 --- a/include/libcamera/internal/ipc_unixsocket.h +++ b/include/libcamera/internal/ipc_unixsocket.h @@ -37,7 +37,7 @@ public: int send(const Payload &payload); int receive(Payload *payload); - Signal readyRead; + Signal<> readyRead; private: struct Header { @@ -48,7 +48,7 @@ private: int sendData(const void *buffer, size_t length, const int32_t *fds, unsigned int num); int recvData(void *buffer, size_t length, int32_t *fds, unsigned int num); - void dataNotifier(EventNotifier *notifier); + void dataNotifier(); int fd_; bool headerReceived_; diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h index 3a7722c2a215..1f2304c19281 100644 --- a/include/libcamera/internal/media_device.h +++ b/include/libcamera/internal/media_device.h @@ -53,7 +53,7 @@ public: MediaLink *link(const MediaPad *source, const MediaPad *sink); int disableLinks(); - Signal disconnected; + Signal<> disconnected; protected: std::string logPrefix() const override; diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h index c4d5d9c1c009..300e0521eb03 100644 --- a/include/libcamera/internal/process.h +++ b/include/libcamera/internal/process.h @@ -38,7 +38,7 @@ public: void kill(); - Signal finished; + Signal finished; private: void closeAllFdsExcept(const std::vector &fds); @@ -70,7 +70,7 @@ public: private: static ProcessManager *self_; - void sighandler(EventNotifier *notifier); + void sighandler(); std::list processes_; diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 423c8fb11845..f21bc3701ca0 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -65,7 +65,7 @@ private: void updateControls(ControlList *ctrls, Span v4l2Ctrls); - void eventAvailable(EventNotifier *notifier); + void eventAvailable(); std::map controlInfo_; std::vector> controlIds_; diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index e767ec84c4da..400d4490d016 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -238,7 +238,7 @@ private: std::unique_ptr createBuffer(unsigned int index); FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); - void bufferAvailable(EventNotifier *notifier); + void bufferAvailable(); FrameBuffer *dequeueBuffer(); V4L2Capability caps_; diff --git a/src/libcamera/base/event_dispatcher_poll.cpp b/src/libcamera/base/event_dispatcher_poll.cpp index 4f22f5793bb9..3c9a126c0bd6 100644 --- a/src/libcamera/base/event_dispatcher_poll.cpp +++ b/src/libcamera/base/event_dispatcher_poll.cpp @@ -278,7 +278,7 @@ void EventDispatcherPoll::processNotifiers(const std::vector &pol } if (pfd.revents & event.events) - notifier->activated.emit(notifier); + notifier->activated.emit(); } /* Erase the notifiers_ entry if it is now empty. */ @@ -300,7 +300,7 @@ void EventDispatcherPoll::processTimers() timers_.pop_front(); timer->stop(); - timer->timeout.emit(timer); + timer->timeout.emit(); } } diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index bd7b73911d12..d0ca30e3d522 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -384,7 +384,7 @@ void Thread::finishThread() data_->running_ = false; data_->mutex_.unlock(); - finished.emit(this); + finished.emit(); data_->cv_.notify_all(); } diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index c20e05014fb9..b5849d4d401a 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -688,7 +688,7 @@ void Camera::disconnect() LOG(Camera, Debug) << "Disconnecting camera " << id(); _d()->disconnect(); - disconnected.emit(this); + disconnected.emit(); } int Camera::exportFrameBuffers(Stream *stream, diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index ec59927eaf34..d12580505303 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -288,7 +288,7 @@ void DeviceEnumerator::removeDevice(const std::string &deviceNode) LOG(DeviceEnumerator, Debug) << "Media device for node " << deviceNode << " removed."; - media->disconnected.emit(media.get()); + media->disconnected.emit(); } /** diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index 37a2c5aa55db..5317afbd77ce 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -327,7 +327,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum) return 0; } -void DeviceEnumeratorUdev::udevNotify([[maybe_unused]] EventNotifier *notifier) +void DeviceEnumeratorUdev::udevNotify() { struct udev_device *dev = udev_monitor_receive_device(monitor_); std::string action(udev_device_get_action(dev)); diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp index 38bcc30a21ed..533560cf95d3 100644 --- a/src/libcamera/ipc_pipe_unixsocket.cpp +++ b/src/libcamera/ipc_pipe_unixsocket.cpp @@ -82,7 +82,7 @@ int IPCPipeUnixSocket::sendAsync(const IPCMessage &data) return 0; } -void IPCPipeUnixSocket::readyRead([[maybe_unused]] IPCUnixSocket *socket) +void IPCPipeUnixSocket::readyRead() { IPCUnixSocket::Payload payload; int ret = socket_->receive(&payload); diff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp index 7188cf29e56a..bd32fca3a678 100644 --- a/src/libcamera/ipc_unixsocket.cpp +++ b/src/libcamera/ipc_unixsocket.cpp @@ -311,7 +311,7 @@ int IPCUnixSocket::recvData(void *buffer, size_t length, return 0; } -void IPCUnixSocket::dataNotifier([[maybe_unused]] EventNotifier *notifier) +void IPCUnixSocket::dataNotifier() { int ret; @@ -342,7 +342,7 @@ void IPCUnixSocket::dataNotifier([[maybe_unused]] EventNotifier *notifier) return; notifier_->setEnabled(false); - readyRead.emit(this); + readyRead.emit(); } } /* namespace libcamera */ diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 597d4c6a578a..f69c4f03b80f 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -448,7 +448,7 @@ void PipelineHandler::registerCamera(std::shared_ptr camera) */ void PipelineHandler::hotplugMediaDevice(MediaDevice *media) { - media->disconnected.connect(this, &PipelineHandler::mediaDeviceDisconnected); + media->disconnected.connect(this, [=]() { mediaDeviceDisconnected(media); }); } /** diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 998d08c2d88a..eca1b30039b8 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -66,7 +66,7 @@ void sigact(int signal, siginfo_t *info, void *ucontext) } /* namespace */ -void ProcessManager::sighandler([[maybe_unused]] EventNotifier *notifier) +void ProcessManager::sighandler() { char data; ssize_t ret = read(pipe_[0], &data, sizeof(data)); @@ -326,7 +326,7 @@ void Process::died(int wstatus) exitStatus_ = WIFEXITED(wstatus) ? NormalExit : SignalExit; exitCode_ = exitStatus_ == NormalExit ? WEXITSTATUS(wstatus) : -1; - finished.emit(this, exitStatus_, exitCode_); + finished.emit(exitStatus_, exitCode_); } /** diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 951592c698f7..9c783c9cbed1 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -705,12 +705,11 @@ void V4L2Device::updateControls(ControlList *ctrls, /** * \brief Slot to handle V4L2 events from the V4L2 device - * \param[in] notifier The event notifier * * When this slot is called, a V4L2 event is available to be dequeued from the * device. */ -void V4L2Device::eventAvailable([[maybe_unused]] EventNotifier *notifier) +void V4L2Device::eventAvailable() { struct v4l2_event event{}; int ret = ioctl(VIDIOC_DQEVENT, &event); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ce60dff6cdfd..1684d0e9c8dd 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1467,7 +1467,6 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) /** * \brief Slot to handle completed buffer events from the V4L2 video device - * \param[in] notifier The event notifier * * When this slot is called, a Buffer has become available from the device, and * will be emitted through the bufferReady Signal. @@ -1475,7 +1474,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) * For Capture video devices the FrameBuffer will contain valid data. * For Output video devices the FrameBuffer can be considered empty. */ -void V4L2VideoDevice::bufferAvailable([[maybe_unused]] EventNotifier *notifier) +void V4L2VideoDevice::bufferAvailable() { FrameBuffer *buffer = dequeueBuffer(); if (!buffer) diff --git a/test/event-thread.cpp b/test/event-thread.cpp index 12021710ef41..ef8a52c3de55 100644 --- a/test/event-thread.cpp +++ b/test/event-thread.cpp @@ -66,7 +66,7 @@ public: } private: - void readReady([[maybe_unused]] EventNotifier *notifier) + void readReady() { size_ = read(notifier_->fd(), data_, sizeof(data_)); notified_ = true; diff --git a/test/event.cpp b/test/event.cpp index e338335c11e8..d4765eb14d12 100644 --- a/test/event.cpp +++ b/test/event.cpp @@ -22,7 +22,7 @@ using namespace libcamera; class EventTest : public Test { protected: - void readReady([[maybe_unused]] EventNotifier *notifier) + void readReady() { size_ = read(notifier_->fd(), data_, sizeof(data_)); notified_ = true; diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 0ee51f71fd87..43562e608506 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -153,7 +153,7 @@ protected: } private: - void readTrace([[maybe_unused]] EventNotifier *notifier) + void readTrace() { ssize_t s = read(notifier_->fd(), &trace_, sizeof(trace_)); if (s < 0) { diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index 6507fb12d74b..7270bf4d2fe7 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -68,7 +68,7 @@ public: } private: - void readyRead([[maybe_unused]] IPCUnixSocket *ipc) + void readyRead() { IPCUnixSocket::Payload message, response; int ret; @@ -447,7 +447,7 @@ private: return 0; } - void readyRead([[maybe_unused]] IPCUnixSocket *ipc) + void readyRead() { if (!callResponse_) { cerr << "Read ready without expecting data, fail." << endl; diff --git a/test/ipc/unixsocket_ipc.cpp b/test/ipc/unixsocket_ipc.cpp index 60317a4956b8..ab5d25572d83 100644 --- a/test/ipc/unixsocket_ipc.cpp +++ b/test/ipc/unixsocket_ipc.cpp @@ -65,7 +65,7 @@ public: } private: - void readyRead([[maybe_unused]] IPCUnixSocket *ipc) + void readyRead() { IPCUnixSocket::Payload message; int ret; diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp index d138aa7ff562..a56a399848a7 100644 --- a/test/log/log_process.cpp +++ b/test/log/log_process.cpp @@ -126,8 +126,7 @@ protected: } private: - void procFinished([[maybe_unused]] Process *proc, - enum Process::ExitStatus exitStatus, int exitCode) + void procFinished(enum Process::ExitStatus exitStatus, int exitCode) { exitStatus_ = exitStatus; exitCode_ = exitCode; diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index 8f7a1f05f681..378d680bf4ef 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -81,8 +81,7 @@ protected: } private: - void procFinished([[maybe_unused]] Process *proc, - enum Process::ExitStatus exitStatus, int exitCode) + void procFinished(enum Process::ExitStatus exitStatus, int exitCode) { exitStatus_ = exitStatus; exitCode_ = exitCode; diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp index 2c14865b74d5..f7e8743da9e6 100644 --- a/test/timer-thread.cpp +++ b/test/timer-thread.cpp @@ -39,7 +39,7 @@ public: } private: - void timeoutHandler([[maybe_unused]] Timer *timer) + void timeoutHandler() { timeout_ = true; } diff --git a/test/timer.cpp b/test/timer.cpp index 88f226e79f5f..be79d0100a58 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -56,7 +56,7 @@ public: } private: - void timeoutHandler([[maybe_unused]] Timer *timer) + void timeoutHandler() { expiration_ = std::chrono::steady_clock::now(); count_++; diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl index b4cd1aa9e823..c54ecdb90a1a 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl @@ -57,7 +57,7 @@ public: ~{{proxy_worker_name}}() {} - void readyRead([[maybe_unused]] IPCUnixSocket *socket) + void readyRead() { IPCUnixSocket::Payload _message; int _retRecv = socket_.receive(&_message);