From patchwork Mon Jul 6 13:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8649 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 3CEF0BD792 for ; Mon, 6 Jul 2020 13:49:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C53BC60E01; Mon, 6 Jul 2020 15:49:34 +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="wmlFr5zC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E40E603AA for ; Mon, 6 Jul 2020 15:49:33 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EF8E797E for ; Mon, 6 Jul 2020 15:49:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594043373; bh=xz0LxTB2KnyOvlJvX+vnocWm0MSl8SqJA+orL6dkxFs=; h=From:To:Subject:Date:From; b=wmlFr5zCsOfFjP2z3IOz22qdgU1OWaGtg0FrAnUIN0QfWs1PnWe6hgkDQOJsDIjPA tcjjjpn7ONKvn22zbf/jBBtoq3MGdoMNJY/j4knqnC48h/nAA3Muxy0iaSmmnT8zDV 2Zgz+y6UnJKLs3aO2pMK2CfAYs8cpegvycudTR70= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 6 Jul 2020 16:49:19 +0300 Message-Id: <20200706134919.19224-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: ipa_proxy: Allow stop() on a stopped IPA 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" To make error handling easier in callers, allow the stop() function to be called when the proxy is already stopped, or not started yet. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- Changes since v1: - Rewrite documentation --- include/libcamera/internal/ipa_proxy.h | 2 ++ src/libcamera/ipa_proxy.cpp | 10 ++++++++++ src/libcamera/proxy/ipa_proxy_thread.cpp | 3 +++ 3 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h index aec8f04ffc15..b429ce5a68a3 100644 --- a/include/libcamera/internal/ipa_proxy.h +++ b/include/libcamera/internal/ipa_proxy.h @@ -27,6 +27,8 @@ public: std::string configurationFile(const std::string &file) const; + void stop() override = 0; + protected: std::string resolvePath(const std::string &file) const; diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 23be24ad9bf1..ff4d7fd18cda 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -145,6 +145,16 @@ std::string IPAProxy::configurationFile(const std::string &name) const return std::string(); } +/** + * \fn IPAProxy::stop() + * \brief Stop the IPA proxy + * + * This function stops the IPA and releases all the resources acquired by the + * proxy in start(). Calling stop() when the IPA proxy hasn't been started or + * has already been stopped is valid, the proxy shall treat this as a no-op and + * shall not forward the call to the IPA. + */ + /** * \brief Find a valid full path for a proxy worker for a given executable name * \param[in] file File name of proxy worker executable diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index aa403e22f297..eead2883708d 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -121,6 +121,9 @@ int IPAProxyThread::start() void IPAProxyThread::stop() { + if (!running_) + return; + running_ = false; proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking);