[{"id":34027,"web_url":"https://patchwork.libcamera.org/comment/34027/","msgid":"<174549421784.2166729.2698814107336907089@ping.linuxembedded.co.uk>","date":"2025-04-24T11:30:17","subject":"Re: [PATCH v2 1/2] libcamera: pipeline: Add function to clear\n\tacquired media devices","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2025-03-26 08:47:58)\n> Some pipeline handler implementations, such as the simple pipeline\n> handler, can encounter systems with multiple media devices that can be\n> supported.\n> \n> In a subsequent patch, the simple pipeline handler will be updated so\n> that it will continue to match other media graphs even if the first\n> media graph it encounters has an invalid media device. In this case,\n> there would be a mix of invalid and valid media devices in\n> mediaDevices_.\n> \n> Add a function to clear mediaDevices_ so that this can be\n> prevented.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n> New in v2\n> ---\n>  include/libcamera/internal/pipeline_handler.h |  2 ++\n>  src/libcamera/pipeline_handler.cpp            | 15 +++++++++++++++\n>  2 files changed, 17 insertions(+)\n> \n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index 972a2fa65310..5fa8bc2f66ee 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -71,6 +71,8 @@ public:\n>         CameraManager *cameraManager() const { return manager_; }\n>  \n>  protected:\n> +       void clearMediaDevices();\n> +\n>         void registerCamera(std::shared_ptr<Camera> camera);\n>         void hotplugMediaDevice(MediaDevice *media);\n>  \n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index d84dff3c9f19..8f12957b75fa 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -142,6 +142,21 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,\n>         return media.get();\n>  }\n>  \n> +/**\n> + * \\brief Clear the list of acquired media devices for this PipelineHandler instance\n> + *\n> + * This is meant to be used when the Pipeline Handler needs to search multiple\n> + * media graphs to create multiple instances of itself, and a partial match\n> + * needs to be canceled as an invalid media device was detected. This is to\n> + * prevent mediaDevices_ from having a mix of invalid media devices from a\n> + * previous failed match and valid media devices from the current succeeding\n> + * match.\n> + */\n> +void PipelineHandler::clearMediaDevices()\n> +{\n> +       mediaDevices_.clear();\n> +}\n> +\n>  /**\n>   * \\brief Acquire exclusive access to the pipeline handler for the process\n>   *\n> -- \n> 2.47.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 267EEBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Apr 2025 11:30:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D52E868AD1;\n\tThu, 24 Apr 2025 13:30:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8C2F68AC7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Apr 2025 13:30:21 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E5B3E16A;\n\tThu, 24 Apr 2025 13:30:19 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RM1pjf/V\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745494220;\n\tbh=+xqHGPtAye3uXR3eaD9eAcllR0x4bjjttrKShHFV7uY=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=RM1pjf/V1Khr1rc53DPBcPAdOn+DtPpnOgzzsJvCPSJOjqAkYUrVlvv4JXhpxEsbY\n\tRHdaIu84CcLZJ1pein/U1mMi9RmVMzdfNLUTm+DBv/pk7mb2h6gwOJCotqMONEFFsV\n\tyCeGHl/vo/nSAjIhIuCK50/Pe4RW0Z8R889tOdCg=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250326084800.1880530-2-paul.elder@ideasonboard.com>","References":"<20250326084800.1880530-1-paul.elder@ideasonboard.com>\n\t<20250326084800.1880530-2-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v2 1/2] libcamera: pipeline: Add function to clear\n\tacquired media devices","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 24 Apr 2025 12:30:17 +0100","Message-ID":"<174549421784.2166729.2698814107336907089@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]