[{"id":19850,"web_url":"https://patchwork.libcamera.org/comment/19850/","msgid":"<YVDk/p0ZYratHysj@pendragon.ideasonboard.com>","date":"2021-09-26T21:24:14","subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Sep 27, 2021 at 12:21:08AM +0300, Laurent Pinchart wrote:\n> The simple-cam application has a check to ensure that at least one\n> camera is present before attempting to access the first camera, to avoid\n> a crash. Update the application developer's guide accordingly.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  Documentation/guides/application-developer.rst | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst\n> index 41a7d88369be..11d3df15825b 100644\n> --- a/Documentation/guides/application-developer.rst\n> +++ b/Documentation/guides/application-developer.rst\n> @@ -109,9 +109,16 @@ the Camera Manager reports as available to applications.\n>  Camera devices are stored by the CameraManager in a list accessible by index, or\n>  can be retrieved by name through the ``CameraManager::get()`` function. The\n>  code below retrieves the name of the first available camera and gets the camera\n> -by name from the Camera Manager.\n> +by name from the Camera Manager, after making sure that at least one camera is\n> +available.\n>  \n>  .. code:: cpp\n\nThis is obviously missing a blank line here :-S I'll fix it in v2 (or\nwhen pushing if no v2 is otherwise needed).\n\n> +   if (cm->cameras().empty()) {\n> +       std::cout << \"No cameras were identified on the system.\"\n> +                 << std::endl;\n> +       cm->stop();\n> +       return EXIT_FAILURE;\n> +   }\n>  \n>     std::string cameraId = cm->cameras()[0]->id();\n>     camera = cm->get(cameraId);","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 E6041BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Sep 2021 21:24:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 194C669191;\n\tSun, 26 Sep 2021 23:24:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8D776012D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Sep 2021 23:24:19 +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 7B351EF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Sep 2021 23:24: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=\"e0Prx4D2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632691459;\n\tbh=bRREn+u4/dce0SJlCN5PcFjT4s0DBTWQ3empo2Ggy00=;\n\th=Date:From:To:Subject:References:In-Reply-To:From;\n\tb=e0Prx4D2bupHwmN4QPIPI63xCgRWb8UiP4nbdbZ5DDr6/Ztzv6/BD8YMMb0OcigwV\n\t1pcAz63lxan5Wx8KFHykSeYAxjcGRRC2rXnlY4EqNMr7gl2R5VOcRqIizmyB52bsWZ\n\t9uVTSAzWgw2UQZKOjlvRRbHdmb5zibiZh+fI87a8=","Date":"Mon, 27 Sep 2021 00:24:14 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Message-ID":"<YVDk/p0ZYratHysj@pendragon.ideasonboard.com>","References":"<20210926212108.22510-1-laurent.pinchart@ideasonboard.com>\n\t<20210926212108.22510-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210926212108.22510-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","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>"}},{"id":19865,"web_url":"https://patchwork.libcamera.org/comment/19865/","msgid":"<20210927065719.GF4382@pyrite.rasen.tech>","date":"2021-09-27T06:57:19","subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Mon, Sep 27, 2021 at 12:21:08AM +0300, Laurent Pinchart wrote:\n> The simple-cam application has a check to ensure that at least one\n> camera is present before attempting to access the first camera, to avoid\n> a crash. Update the application developer's guide accordingly.\n\ns/accordingly/to match this behavior/ ?\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  Documentation/guides/application-developer.rst | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst\n> index 41a7d88369be..11d3df15825b 100644\n> --- a/Documentation/guides/application-developer.rst\n> +++ b/Documentation/guides/application-developer.rst\n> @@ -109,9 +109,16 @@ the Camera Manager reports as available to applications.\n>  Camera devices are stored by the CameraManager in a list accessible by index, or\n>  can be retrieved by name through the ``CameraManager::get()`` function. The\n>  code below retrieves the name of the first available camera and gets the camera\n> -by name from the Camera Manager.\n> +by name from the Camera Manager, after making sure that at least one camera is\n> +available.\n>  \n>  .. code:: cpp\n> +   if (cm->cameras().empty()) {\n> +       std::cout << \"No cameras were identified on the system.\"\n> +                 << std::endl;\n> +       cm->stop();\n> +       return EXIT_FAILURE;\n> +   }\n>  \n>     std::string cameraId = cm->cameras()[0]->id();\n>     camera = cm->get(cameraId);\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 5B674BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Sep 2021 06:57:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BCA9B6918C;\n\tMon, 27 Sep 2021 08:57:28 +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 6903D684C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Sep 2021 08:57:27 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0AEEC49A;\n\tMon, 27 Sep 2021 08:57:25 +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=\"nwdY8od/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632725847;\n\tbh=iYAL4NKpp1NzGvsY0IfbZF40cbCjjakJ5y5AHvz3vZw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nwdY8od/K9NWEXbBKAIN++J+rtX4QSUSGxrSDozxketeoNPsMQJZ8goq9KeT8T1fv\n\tfdMzt76ECXuovXbFthmXyaLDSSs5B9gw1vqGRCDZ6g/sjs4zhqG2xUnYIPWIL7jR8t\n\thpph9QXxSeAQzPY7GyhgEvVih7CPdXeEBKj5wrX4=","Date":"Mon, 27 Sep 2021 15:57:19 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210927065719.GF4382@pyrite.rasen.tech>","References":"<20210926212108.22510-1-laurent.pinchart@ideasonboard.com>\n\t<20210926212108.22510-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210926212108.22510-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19880,"web_url":"https://patchwork.libcamera.org/comment/19880/","msgid":"<20210927122206.gfzpful44pkds3pg@ideasonboard.com>","date":"2021-09-27T12:22:06","subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On Mon, Sep 27, 2021 at 12:24:14AM +0300, Laurent Pinchart wrote:\n> On Mon, Sep 27, 2021 at 12:21:08AM +0300, Laurent Pinchart wrote:\n> > The simple-cam application has a check to ensure that at least one\n> > camera is present before attempting to access the first camera, to avoid\n> > a crash. Update the application developer's guide accordingly.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  Documentation/guides/application-developer.rst | 9 ++++++++-\n> >  1 file changed, 8 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst\n> > index 41a7d88369be..11d3df15825b 100644\n> > --- a/Documentation/guides/application-developer.rst\n> > +++ b/Documentation/guides/application-developer.rst\n> > @@ -109,9 +109,16 @@ the Camera Manager reports as available to applications.\n> >  Camera devices are stored by the CameraManager in a list accessible by index, or\n> >  can be retrieved by name through the ``CameraManager::get()`` function. The\n> >  code below retrieves the name of the first available camera and gets the camera\n> > -by name from the Camera Manager.\n> > +by name from the Camera Manager, after making sure that at least one camera is\n> > +available.\n> >  \n> >  .. code:: cpp\n> \n> This is obviously missing a blank line here :-S I'll fix it in v2 (or\n> when pushing if no v2 is otherwise needed).\n> \n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> > +   if (cm->cameras().empty()) {\n> > +       std::cout << \"No cameras were identified on the system.\"\n> > +                 << std::endl;\n> > +       cm->stop();\n> > +       return EXIT_FAILURE;\n> > +   }\n> >  \n> >     std::string cameraId = cm->cameras()[0]->id();\n> >     camera = cm->get(cameraId);\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 7912EC3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Sep 2021 12:22:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3CFAD6918B;\n\tMon, 27 Sep 2021 14:22:09 +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 186416012C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Sep 2021 14:22:08 +0200 (CEST)","from ideasonboard.com\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 B62A3B91;\n\tMon, 27 Sep 2021 14:22:07 +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=\"FnuuIBhk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632745327;\n\tbh=HMGBXnTikChXI8kTU5ow0f0EpKbAzU9njw4O1WXoT0s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FnuuIBhk9bRgqFyQwju9ONhT8OP+iNaz2HWy344IOc5PfvOyTL8Q3ZCvsbbd2lHTB\n\tioUg40fb/wSakOt+f0QNevv9hK+XXkxVb6K0fHt5Uu8uKwbBzPM/rW8+gzmLUp3jnL\n\tdHUHokjJaGqiBbgS0yZXgJZqkOTj+mxVfOyt5YqY=","Date":"Mon, 27 Sep 2021 13:22:06 +0100","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210927122206.gfzpful44pkds3pg@ideasonboard.com>","References":"<20210926212108.22510-1-laurent.pinchart@ideasonboard.com>\n\t<20210926212108.22510-3-laurent.pinchart@ideasonboard.com>\n\t<YVDk/p0ZYratHysj@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<YVDk/p0ZYratHysj@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] Documentation:\n\tapplication-developer: Add camera detection check","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]