From patchwork Sun Sep 26 21:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13940 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 23F55BDC71 for ; Sun, 26 Sep 2021 21:21:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 59B4069193; Sun, 26 Sep 2021 23:21:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="anQp44m4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C626012D for ; Sun, 26 Sep 2021 23:21:17 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 975CBEF for ; Sun, 26 Sep 2021 23:21:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632691276; bh=3UhWg7gW0Xx2VJ2FBz+Mv1x1xOFk6RFxLW2QcxI08oY=; h=From:To:Subject:Date:From; b=anQp44m4hGw/Q/CmcizBxCCaEmapBwEhULerG9itoESU2/8BgUW8U9k07YpfrBztq 65vovotP5tGZvr11HPQOClz4miAZqE1A0UvRAozimOtKYMNwDOg/+7hwsLTfMntjUL eq7AvWr4D20OtC5wIewDLQKkRNRQ9aBOp4lJyCEc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Sep 2021 00:21:06 +0300 Message-Id: <20210926212108.22510-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] Documentation: application-developer: Make global variable static X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The global "camera" variable isn't accessed outside of its compilation unit. Make it static. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Kieran Bingham --- Documentation/guides/application-developer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 72e8e03719aa552abce7eeee8a6e4a9b8eb8443e diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index ae28c96b5aca..3de13060db08 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -58,7 +58,7 @@ variable for the camera to support the event call back later: .. code:: cpp - std::shared_ptr camera; + static std::shared_ptr camera; Create a Camera Manager instance at the beginning of the main function, and then start it. An application must only create a single Camera Manager instance. From patchwork Sun Sep 26 21:21:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13941 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A8176BDC71 for ; Sun, 26 Sep 2021 21:21:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2DF0869195; Sun, 26 Sep 2021 23:21:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="M7brjBzh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63C9F6918C for ; Sun, 26 Sep 2021 23:21:17 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F0281BB0 for ; Sun, 26 Sep 2021 23:21:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632691277; bh=OEAu3s59Esl9Hv3rq2npQpPU9I+SGmsN7uKL2PgUk7g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M7brjBzhOm4E6dLgCKToeymFDM0emZNXrhdFV8mtEOKvSnL9a0giHBPvsa6tQWQV/ iO67jspXSK7FKIqf03c27Bz4e6wTci5kn0U/s2AWl4x92LMgv1rERWMtZ82/dHab9W VVJsE1FWNZJeb58Jise0QF6KfUi4Nw2WMx4DAeDc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Sep 2021 00:21:07 +0300 Message-Id: <20210926212108.22510-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210926212108.22510-1-laurent.pinchart@ideasonboard.com> References: <20210926212108.22510-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] Documentation: application-developer: Use correct type to store size X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The return type of std::vector::size() is size_t. Use the same type, instead of unsigned int, to store its return value when retrieving the number of allocated buffers. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- Documentation/guides/application-developer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 3de13060db08..41a7d88369be 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -278,7 +278,7 @@ as the parameter of the ``FrameBufferAllocator::buffers()`` function. return -ENOMEM; } - unsigned int allocated = allocator->buffers(cfg.stream()).size(); + size_t allocated = allocator->buffers(cfg.stream()).size(); std::cout << "Allocated " << allocated << " buffers for stream" << std::endl; } From patchwork Sun Sep 26 21:21:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13942 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BECA8BDC71 for ; Sun, 26 Sep 2021 21:21:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 192AB69196; Sun, 26 Sep 2021 23:21:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bgRMjNTY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B49BE6918C for ; Sun, 26 Sep 2021 23:21:17 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 565C0EF for ; Sun, 26 Sep 2021 23:21:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632691277; bh=TR+ZJaJoSYN3LVeVnSyz1vepTTzQqgphN7g9/FMDlEs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bgRMjNTYmDWt44Yyxblp5LGxjSYwkTfAcnBwBfIdpYztUu7fL4GkYBVnMAUxSc+EF 3MqoPNQiPI1V3BxwRECjuJnsz91/EbFnHnr9YiFLrU8fGhoiuEwoXcj8q+PCtt0Vkc OjO/XAoUvSoLl7qVZdirLNNyjunbtXpz1G5OmS/A= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Sep 2021 00:21:08 +0300 Message-Id: <20210926212108.22510-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210926212108.22510-1-laurent.pinchart@ideasonboard.com> References: <20210926212108.22510-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] Documentation: application-developer: Add camera detection check X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The simple-cam application has a check to ensure that at least one camera is present before attempting to access the first camera, to avoid a crash. Update the application developer's guide accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- Documentation/guides/application-developer.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 41a7d88369be..11d3df15825b 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -109,9 +109,16 @@ the Camera Manager reports as available to applications. Camera devices are stored by the CameraManager in a list accessible by index, or can be retrieved by name through the ``CameraManager::get()`` function. The code below retrieves the name of the first available camera and gets the camera -by name from the Camera Manager. +by name from the Camera Manager, after making sure that at least one camera is +available. .. code:: cpp + if (cm->cameras().empty()) { + std::cout << "No cameras were identified on the system." + << std::endl; + cm->stop(); + return EXIT_FAILURE; + } std::string cameraId = cm->cameras()[0]->id(); camera = cm->get(cameraId);