[{"id":1592,"web_url":"https://patchwork.libcamera.org/comment/1592/","msgid":"<20190511133603.GJ4946@pendragon.ideasonboard.com>","date":"2019-05-11T13:36:03","subject":"Re: [libcamera-devel] [PATCH v3 10/11] libcamera: pipeline_handler:\n\tAdd functions to lock a whole pipeline","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sat, May 11, 2019 at 11:19:06AM +0200, Niklas Söderlund wrote:\n> Add lock() and unlock() which are backed by the MediaDevice\n> implementation and will lock all media devices claimed by a pipeline\n\ns/will lock/lock/\n\n> handler instance.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/include/pipeline_handler.h |  3 ++\n>  src/libcamera/pipeline_handler.cpp       | 38 ++++++++++++++++++++++++\n>  2 files changed, 41 insertions(+)\n> \n> diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\n> index 4c13496246c2251c..019c8f4751a8c2b2 100644\n> --- a/src/libcamera/include/pipeline_handler.h\n> +++ b/src/libcamera/include/pipeline_handler.h\n> @@ -57,6 +57,9 @@ public:\n>  \tMediaDevice *tryAcquire(DeviceEnumerator *enumerator,\n>  \t\t\t\tconst DeviceMatch &dm);\n>  \n> +\tbool lock();\n> +\tvoid unlock();\n> +\n>  \tvirtual CameraConfiguration\n>  \tstreamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;\n>  \tvirtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0;\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 8f50ef51f0c23301..84e40e4672518d1f 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -182,6 +182,44 @@ out:\n>  \treturn media.get();\n>  }\n>  \n> +/**\n> + * \\brief Lock all media devices acquired by the pipeline\n> + *\n> + * This method shall not be called from a pipeline handler implementation\n> + * directly, as the Camera handles this on the behalf of the specified\n> + * implementation.\n\nI'm not sure what you mean by \"on the behalf of the specified\nimplementation\". How about just \"This method shall not be called from\npipeline handler implementation, as the Camera class handles locking\ndirectly.\" ?\n\n> + *\n> + * \\return True if the devices could be locked, false otherwise\n> + * \\sa unlock()\n> + * \\sa MediaDevice::lock()\n> + */\n> +bool PipelineHandler::lock()\n> +{\n> +\tfor (std::shared_ptr<MediaDevice> &media : mediaDevices_) {\n> +\t\tif (!media->lock()) {\n> +\t\t\tunlock();\n> +\t\t\treturn false;\n> +\t\t}\n> +\t}\n> +\n> +\treturn true;\n> +}\n> +\n> +/**\n> + * \\brief Unlock all media devices acquired by the pipeline\n> + *\n> + * This method shall not be called from a pipeline handler implementation\n> + * directly, as the Camera handles this on the behalf of the specified\n> + * implementation.\n\nSame comment here. Apart from this,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + *\n> + * \\sa lock()\n> + */\n> +void PipelineHandler::unlock()\n> +{\n> +\tfor (std::shared_ptr<MediaDevice> &media : mediaDevices_)\n> +\t\tmedia->unlock();\n> +}\n> +\n>  /**\n>   * \\fn PipelineHandler::streamConfiguration()\n>   * \\brief Retrieve a group of stream configurations for a specified camera","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9966B60E4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 11 May 2019 15:36:19 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19376D5;\n\tSat, 11 May 2019 15:36:19 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1557581779;\n\tbh=q6kJu8YGWoNmpkQ2Nl2cYguB+6axD0dchqDZlk6n9W0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XInxrRmgNQ6V8a95iy+8p+GvqEKtEUosnQR+DS++zwhZI1YyWKEqA0eWkFm2ZeSd8\n\tE9Une5cMIRqRabtpp6/oTLmlwMH9WYWCqeIeuldVlUUDh12opKA+1ROv9/LKMNwOF/\n\t+LeybqpP7nLuFHRkXBAg3NdAX0sQho+USHx1iYj0=","Date":"Sat, 11 May 2019 16:36:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190511133603.GJ4946@pendragon.ideasonboard.com>","References":"<20190511091907.10050-1-niklas.soderlund@ragnatech.se>\n\t<20190511091907.10050-11-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190511091907.10050-11-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 10/11] libcamera: pipeline_handler:\n\tAdd functions to lock a whole pipeline","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sat, 11 May 2019 13:36:19 -0000"}}]