From patchwork Fri Jan 25 17:03:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 388 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0550960C65 for ; Fri, 25 Jan 2019 18:04:11 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 8D2E5200007; Fri, 25 Jan 2019 17:04:10 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 18:03:56 +0100 Message-Id: <20190125170400.24821-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125170400.24821-1-jacopo@jmondi.org> References: <20190125170400.24821-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: pipeline: Fix operator= declaration 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: Fri, 25 Jan 2019 17:04:11 -0000 Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 0db8421..ca77a40 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -29,7 +29,7 @@ protected: private: CameraData(const CameraData &) = delete; - void operator=(const CameraData &) = delete; + CameraData &operator=(const CameraData &) = delete; }; class PipelineHandler : public std::enable_shared_from_this From patchwork Fri Jan 25 17:03:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 389 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9FF6460C65 for ; Fri, 25 Jan 2019 18:04:11 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 303DC20000D; Fri, 25 Jan 2019 17:04:11 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 18:03:57 +0100 Message-Id: <20190125170400.24821-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125170400.24821-1-jacopo@jmondi.org> References: <20190125170400.24821-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: pipeline: Remove duplicated include 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: Fri, 25 Jan 2019 17:04:11 -0000 Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline_handler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 4d53449..cca5576 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -12,8 +12,6 @@ #include "media_device.h" #include "pipeline_handler.h" -#include - /** * \file pipeline_handler.h * \brief Create pipelines and cameras from a set of media devices From patchwork Fri Jan 25 17:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 390 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 37D6E60C7F for ; Fri, 25 Jan 2019 18:04:12 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id C4537200004; Fri, 25 Jan 2019 17:04:11 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 18:03:58 +0100 Message-Id: <20190125170400.24821-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125170400.24821-1-jacopo@jmondi.org> References: <20190125170400.24821-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: pipeline: Rework class destructor 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: Fri, 25 Jan 2019 17:04:12 -0000 Remove comment and do not delete a class member, as it will be destroyed already with the instance that contains it. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline_handler.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cca5576..e75bf0f 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -71,15 +71,8 @@ PipelineHandler::PipelineHandler(CameraManager *manager) { } -/** - * \brief Delete the pipeline handler - * - * Release the cameraData_ map, causing all data there referenced to be - * deleted, as they are stored as unique_ptr - */ PipelineHandler::~PipelineHandler() { - cameraData_.clear(); }; /** From patchwork Fri Jan 25 17:03:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 391 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C961960C7F for ; Fri, 25 Jan 2019 18:04:12 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 621B220000C; Fri, 25 Jan 2019 17:04:12 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 18:03:59 +0100 Message-Id: <20190125170400.24821-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125170400.24821-1-jacopo@jmondi.org> References: <20190125170400.24821-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] libcamera: pipeline: Misc comments update 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: Fri, 25 Jan 2019 17:04:13 -0000 Apply some comments improvements pointed out during review. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline_handler.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index e75bf0f..dc55f8f 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -100,7 +100,7 @@ PipelineHandler::~PipelineHandler() * one pipeline instance, until all compatible media devices are exhausted. * * If this function returns true, a new instance of the pipeline handler will - * be created and its match() function called, + * be created and its match() function called. * * \return true if media devices have been acquired and camera instances * created, or false otherwise @@ -184,11 +184,12 @@ void PipelineHandler::mediaDeviceDisconnected(MediaDevice *media) /** * \brief Retrieve the pipeline-specific data associated with a Camera - * \param camera The camera data is associate with + * \param camera The camera whose data to retrieve * * \return A pointer to the pipeline-specific data set with setCameraData(). - * The returned pointer lifetime is associated with the one of the pipeline - * handler, and caller of this function shall never release it manually. + * The returned pointer is a borrowed reference and is guaranteed to remain + * valid until the pipeline handler is destroyed. It shall not be deleted + * manually by the caller. */ CameraData *PipelineHandler::cameraData(const Camera *camera) { @@ -203,13 +204,13 @@ CameraData *PipelineHandler::cameraData(const Camera *camera) } /** - * \brief Set pipeline-specific data in the camera + * \brief Set pipeline-specific data for the camera * \param camera The camera to associate data to * \param data The pipeline-specific data * * This method allows pipeline handlers to associate pipeline-specific - * information with \a camera. The \a data lifetime gets associated with - * the pipeline handler one, and gets released at deletion time. + * information with \a camera. Ownership of \a data is transferred to + * the PipelineHandler. * * If pipeline-specific data has already been associated with the camera by a * previous call to this method, is it replaced by \a data and the previous data From patchwork Fri Jan 25 17:04:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 392 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 631E160C82 for ; Fri, 25 Jan 2019 18:04:13 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 00A1B200004; Fri, 25 Jan 2019 17:04:12 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 18:04:00 +0100 Message-Id: <20190125170400.24821-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125170400.24821-1-jacopo@jmondi.org> References: <20190125170400.24821-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] libcamera: pipeline: Refuse to substitute camera data 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: Fri, 25 Jan 2019 17:04:14 -0000 Once a pipeline-specific data has been associated with a camera, refuse to update it in order to avoid invalidating the previously set reference, which might still be owned by the caller. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/include/pipeline_handler.h | 2 +- src/libcamera/pipeline_handler.cpp | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index ca77a40..01a0f0b 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -47,7 +47,7 @@ protected: void hotplugMediaDevice(MediaDevice *media); CameraData *cameraData(const Camera *camera); - void setCameraData(const Camera *camera, std::unique_ptr data); + int setCameraData(const Camera *camera, std::unique_ptr data); private: virtual void disconnect(); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index dc55f8f..7e927a7 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -212,21 +212,26 @@ CameraData *PipelineHandler::cameraData(const Camera *camera) * information with \a camera. Ownership of \a data is transferred to * the PipelineHandler. * - * If pipeline-specific data has already been associated with the camera by a - * previous call to this method, is it replaced by \a data and the previous data - * are deleted, rendering all references to them invalid. + * Once pipeline-specific data has already been associated with the camera + * by a previous call to this method it cannot be changed later on. * * The data can be retrieved by pipeline handlers using the cameraData() method. + * + * \return 0 on success, or a negative error code if camera specific data have + * already been set */ -void PipelineHandler::setCameraData(const Camera *camera, - std::unique_ptr data) +int PipelineHandler::setCameraData(const Camera *camera, + std::unique_ptr data) { - if (cameraData_.count(camera)) - LOG(Pipeline, Debug) - << "Replacing data associated with " - << camera->name(); + if (cameraData_.find(camera) != cameraData_.end()) { + LOG(Pipeline, Error) + << "Replacing data associated with a camera is forbidden "; + return -EINVAL; + } cameraData_[camera] = std::move(data); + + return 0; } /**