[{"id":19041,"web_url":"https://patchwork.libcamera.org/comment/19041/","msgid":"<20210825090750.d73nlezbldncwgke@uno.localdomain>","date":"2021-08-25T09:07:50","subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n\nOn Tue, Aug 24, 2021 at 03:24:47PM +0100, Kieran Bingham wrote:\n> The CameraManager should be released when it is no longer used. A\n> unique_ptr will handle this automatically, and convey the lifetime of\n> the object.\n>\n> Update simple-cam to show that managing the lifetime of the\n> CameraManager is recommended practice.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  simple-cam.cpp | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n>\n> diff --git a/simple-cam.cpp b/simple-cam.cpp\n> index 8f7012b83b6c..5c16db67700c 100644\n> --- a/simple-cam.cpp\n> +++ b/simple-cam.cpp\n> @@ -131,8 +131,15 @@ int main()\n>  \t *\n>  \t * The CameraManager provides a list of available Cameras that\n>  \t * applications can operate on.\n> +\t *\n> +\t * When the CameraManager is no longer to be used, it should be deleted.\n> +\t * We use a unique_ptr here to manage the lifetime automatically during\n> +\t * the scope of this function.\n> +\t *\n> +\t * There can only be a single CameraManager constructed within any\n> +\t * process space.\n>  \t */\n> -\tCameraManager *cm = new CameraManager();\n> +\tstd::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();\n\nAssuming there are no 'delete cm' leftovers in the code base\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n>  \tcm->start();\n>\n>  \t/*\n> --\n> 2.30.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 CD56ABD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Aug 2021 09:07:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 27B7B688A3;\n\tWed, 25 Aug 2021 11:07:05 +0200 (CEST)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 91D7960259\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Aug 2021 11:07:03 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id CC5F8C0002;\n\tWed, 25 Aug 2021 09:07:02 +0000 (UTC)"],"Date":"Wed, 25 Aug 2021 11:07:50 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20210825090750.d73nlezbldncwgke@uno.localdomain>","References":"<20210824142450.3157833-1-kieran.bingham@ideasonboard.com>\n\t<20210824142450.3157833-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210824142450.3157833-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19046,"web_url":"https://patchwork.libcamera.org/comment/19046/","msgid":"<72a1ffda-cf08-e009-bbe7-ca2489f18e8d@ideasonboard.com>","date":"2021-08-25T09:44:23","subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi JM,\n\nOn 25/08/2021 10:07, Jacopo Mondi wrote:\n> Hi Kieran,\n> \n> On Tue, Aug 24, 2021 at 03:24:47PM +0100, Kieran Bingham wrote:\n>> The CameraManager should be released when it is no longer used. A\n>> unique_ptr will handle this automatically, and convey the lifetime of\n>> the object.\n>>\n>> Update simple-cam to show that managing the lifetime of the\n>> CameraManager is recommended practice.\n>>\n>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>> ---\n>>  simple-cam.cpp | 9 ++++++++-\n>>  1 file changed, 8 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/simple-cam.cpp b/simple-cam.cpp\n>> index 8f7012b83b6c..5c16db67700c 100644\n>> --- a/simple-cam.cpp\n>> +++ b/simple-cam.cpp\n>> @@ -131,8 +131,15 @@ int main()\n>>  \t *\n>>  \t * The CameraManager provides a list of available Cameras that\n>>  \t * applications can operate on.\n>> +\t *\n>> +\t * When the CameraManager is no longer to be used, it should be deleted.\n>> +\t * We use a unique_ptr here to manage the lifetime automatically during\n>> +\t * the scope of this function.\n>> +\t *\n>> +\t * There can only be a single CameraManager constructed within any\n>> +\t * process space.\n>>  \t */\n>> -\tCameraManager *cm = new CameraManager();\n>> +\tstd::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();\n> \n> Assuming there are no 'delete cm' leftovers in the code base\n\nThere are not. Previously it was leaking (though right at the end before\nthe application closed, so it didn't matter too much)\n\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n\n> \n> Thanks\n>    j\n> \n>>  \tcm->start();\n>>\n>>  \t/*\n>> --\n>> 2.30.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 3CA1FBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Aug 2021 09:44:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AB32C688A3;\n\tWed, 25 Aug 2021 11:44:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3DA7660259\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Aug 2021 11:44:27 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A85F324F;\n\tWed, 25 Aug 2021 11:44:26 +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=\"Gs/uzvfT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629884666;\n\tbh=+sflKIdbV2oHi3puUA1DRrUSYnIVbL5ooQ5j2jy9ouA=;\n\th=From:Subject:To:Cc:References:Date:In-Reply-To:From;\n\tb=Gs/uzvfT+KDJfSaR3osdSyE1oCR8kMyDzA3I+YsrFGpmW74/DA9A69mgll6xQebVv\n\tW2DsJKeY/i6YIyD9ygeS0kamE+ms8Q6vvR9uIvXQjoRu704QeVH/HrFWudM7QPTW6R\n\tzC4pRKFL4YI1lGoOlLUUIs1M0WkWnRulZRt6ZGSY=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","References":"<20210824142450.3157833-1-kieran.bingham@ideasonboard.com>\n\t<20210824142450.3157833-2-kieran.bingham@ideasonboard.com>\n\t<20210825090750.d73nlezbldncwgke@uno.localdomain>","Message-ID":"<72a1ffda-cf08-e009-bbe7-ca2489f18e8d@ideasonboard.com>","Date":"Wed, 25 Aug 2021 10:44:23 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210825090750.d73nlezbldncwgke@uno.localdomain>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19068,"web_url":"https://patchwork.libcamera.org/comment/19068/","msgid":"<YSag0lpHEjE/FCo2@pendragon.ideasonboard.com>","date":"2021-08-25T19:58:10","subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Tue, Aug 24, 2021 at 03:24:47PM +0100, Kieran Bingham wrote:\n> The CameraManager should be released when it is no longer used. A\n> unique_ptr will handle this automatically, and convey the lifetime of\n> the object.\n> \n> Update simple-cam to show that managing the lifetime of the\n> CameraManager is recommended practice.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  simple-cam.cpp | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/simple-cam.cpp b/simple-cam.cpp\n> index 8f7012b83b6c..5c16db67700c 100644\n> --- a/simple-cam.cpp\n> +++ b/simple-cam.cpp\n> @@ -131,8 +131,15 @@ int main()\n>  \t *\n>  \t * The CameraManager provides a list of available Cameras that\n>  \t * applications can operate on.\n> +\t *\n> +\t * When the CameraManager is no longer to be used, it should be deleted.\n> +\t * We use a unique_ptr here to manage the lifetime automatically during\n> +\t * the scope of this function.\n> +\t *\n> +\t * There can only be a single CameraManager constructed within any\n> +\t * process space.\n>  \t */\n> -\tCameraManager *cm = new CameraManager();\n> +\tstd::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();\n>  \tcm->start();\n>  \n>  \t/*","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 DD5F8BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Aug 2021 19:58:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6011768893;\n\tWed, 25 Aug 2021 21:58:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3BDC60288\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Aug 2021 21:58:22 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B78C24F;\n\tWed, 25 Aug 2021 21:58:22 +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=\"utIP1zYM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629921502;\n\tbh=RvBHE1HxZtiQn+E7X3laP9RvtQ31PJY14bIGhqSuW1E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=utIP1zYMyzEUXddZz7Xz4wCVHFjjsqFRIbvleux8iAWtX4OrfxaV3TCg/Pgq4Octs\n\t/ivmqvzEW6OdXfENrIW1/ce9gcU76F3Wd0cS5qL8rQymBM7ENnZ6cB521vvIlJTrrm\n\tZVLL7NfILbXaDvo8ZMAD+J2KbUT+9or2crlPnvx8=","Date":"Wed, 25 Aug 2021 22:58:10 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YSag0lpHEjE/FCo2@pendragon.ideasonboard.com>","References":"<20210824142450.3157833-1-kieran.bingham@ideasonboard.com>\n\t<20210824142450.3157833-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210824142450.3157833-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [SimpleCam PATCH 1/4] simple-cam: Use a\n\tunique_ptr for the CameraManager","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]