From patchwork Wed Jun 15 16:25:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16223 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 A826EC3273 for ; Wed, 15 Jun 2022 16:26:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15DC665639; Wed, 15 Jun 2022 18:26:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655310405; bh=X9HxjkGgahIjpIqPOxLoBMPUddryFeMIEMmF7uB1Kbk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rdQvHCiOe8uDhdIGiPYmMCf09RmuKLsQpUh5PPOmMW8+3Uqjor9M6izraWX4QHSdo 3HIsKaxaOclPqDZ1YnceYX4wSh1E3pbd6Gmcka5tnHo7ZZAgp8KTbedzGNN+c2dBOP bCaCg7+I/hSH3pnfRfFO+8TIxt4O0MKAmmQyOe+62aEDLhlyU8sWigctx1QmBsOlR/ NtYxpijRuTsNZ0wL/4OVpo29V0Gg1MqP4IqwQbPIaHv7JakdS9ATXE+W4Kg3vLILxI fs3X8GSGMxOekCiFzPYO6WMMBJfw/52+BAUx/mEXmiyczRDCxGDBq5bc3usYZ0Lx5G aiqWtwZClMLrQ== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0482B65631 for ; Wed, 15 Jun 2022 18:26:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="KhI7O/ng"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id s1so16072259wra.9 for ; Wed, 15 Jun 2022 09:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hVAZs+2KGFmhbFIx3lcuE8BvVnEh3FH6A/D87gHArzE=; b=KhI7O/ng6lCmIxkf0coHxJbuD2Grdrpn33Vqjw2SChkZzQjebsoK7wjzGUJIgamQTu MDfD22fRkSx/VB0AcBwhZcWysbw23pflSUUz1osdQv3NnIRFp4m0LzxIq2ssFALwA7jd Wa5NiXlsoCqNUabDZ/seFC2jbYuWmBddSlnnFnbvmFHd3AyBjTqaXErXbo9fe2AVzrII Y5vnhCRRWM7xt7N7NYsX86aJTkms++SJpje/ehyJzcCOXl7xKXjyd+FxyAqojnuSBC+9 NSmXstntj3nfbxORsac3UhtZTUEbwS3q8364GcTiruwrLa0xz8m2lu5hYRlC48EzSTTg yL6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hVAZs+2KGFmhbFIx3lcuE8BvVnEh3FH6A/D87gHArzE=; b=xElDaBRajTeMAKzh4IxHErC4JA8nAPUpS/8qSxRsTrFkwlGuJ3bGBAy/u7LGP8kcOs PIE6jjYao+CD2UlBeVIXLS7+uj/JmQ7w4mbupP+W0BfGXUS3vAWOn7zPK5wFQEoGG3i/ o3aMC38OmYn27zpCkFcxfRxtML3lW0TZqWHU23aKNOxgsG2W4+lbJcKJ/1gwguR8dhiv IRC7PS27Ze2ffLW+utkW6xqs7S4VQD1HRfakfK2ZvyhCbWZFzxuRTsb7BH7MfFWJpGIS MO7aF/U72l/2O6Y0BfF3ofNNvCbwsEH8HcdHljKMtQS5dfhbQ3fA7qrhq2ubFHQyC3qX 2gbg== X-Gm-Message-State: AJIora/wga0swIkr0PSWKvNqUHSKwrBd2FMICosu+w1DYRMgPNbYalO5 Tu3WoUsPxsqw8mWYZBLQGQbRWHPIIcbFxHYF X-Google-Smtp-Source: AGRyM1tHLurMzmC+LZEE3KVPZkK/uvTESdIYnbCkzq8Egj5erWQcjt47rDfzJBkY/pNMA7XZxI5lZA== X-Received: by 2002:a05:6000:18a8:b0:212:ae71:a3f6 with SMTP id b8-20020a05600018a800b00212ae71a3f6mr549010wri.635.1655310403757; Wed, 15 Jun 2022 09:26:43 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r17-20020a05600c35d100b0039c8d181ac6sm3135772wmq.26.2022.06.15.09.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:26:43 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Jun 2022 18:25:59 +0200 Message-Id: <20220615162601.48619-2-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615162601.48619-1-dse@thaumatec.com> References: <20220615162601.48619-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] Documentation: Update code examples to match Request related changes 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: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" - Camera::createRequest() now returns unique_ptr instead of raw pointer - Request::BufferMap key type is now const --- Documentation/guides/application-developer.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 16bea9c4..6ab8b7e5 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -308,7 +308,7 @@ the camera. Stream *stream = streamConfig.stream(); const std::vector> &buffers = allocator->buffers(stream); - std::vector requests; + std::vector> requests; Proceed to fill the request vector by creating ``Request`` instances from the camera device, and associate a buffer for each of them for the ``Stream``. @@ -316,7 +316,7 @@ camera device, and associate a buffer for each of them for the ``Stream``. .. code:: cpp for (unsigned int i = 0; i < buffers.size(); ++i) { - Request *request = camera->createRequest(); + std::unique_ptr request = camera->createRequest(); if (!request) { std::cerr << "Can't create request" << std::endl; @@ -332,7 +332,7 @@ camera device, and associate a buffer for each of them for the ``Stream``. return ret; } - requests.push_back(request); + requests.push_back(std::move(request)); } .. TODO: Controls @@ -410,7 +410,7 @@ images. .. code:: cpp - const std::map &buffers = request->buffers(); + const std::map &buffers = request->buffers(); Iterating through the map allows applications to inspect each completed buffer in this request, and access the metadata associated to each frame. @@ -517,8 +517,8 @@ and queue all the previously created requests. .. code:: cpp camera->start(); - for (Request *request : requests) - camera->queueRequest(request); + for (std::unique_ptr &request : requests) + camera->queueRequest(request.get()); Start an event loop ~~~~~~~~~~~~~~~~~~~ From patchwork Wed Jun 15 16:26:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16224 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 9D167C3274 for ; Wed, 15 Jun 2022 16:26:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E18BC65637; Wed, 15 Jun 2022 18:26:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655310407; bh=Rth15gJjGXY9HttBrm5pmAqhlqdqMAWx6LM4ZHUDCF8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yDDlp+k8L4hO7XxqEWix10aaTaSB5unlkBvR6R33+URguSNjstGSYRzZKj8cioomm Vona1p2DhDviXANxQzA7aK8uk/JM3rSzW+1Hbwu/B+EjU0c8dbMq+wsa2K4OPbSf5P ruMdR4+Ne8vi3HgZWboi7Ia/Qh7yNUP1jgOs/0thh4v5TaphI+p+sON7bb/HJiqryF ezT1o8myGxgGD+TzjJ+YJhmv+0TEwBKnz49QS1qoRcPddwBEL7BF1VQZ6sNPmgL6JH mKo86pPuek7mzFXwcvFvY+Owt6VouxuPREWIsLaiY4n+B4k4drbfQWx81NQ7uQWbpd hooERAk5gO6oQ== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 54E9465631 for ; Wed, 15 Jun 2022 18:26:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="s+GQyrTn"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id o16so16097916wra.4 for ; Wed, 15 Jun 2022 09:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x5pmzjoZiXuT0DHzxI2DxQ95Z5ycnNU6zzqPLmhAnlU=; b=s+GQyrTniuUhtO44nv0Hkh40UPf1ldcek95NPpnJhsUo71emL+H4TMUYrySuACXGd2 Gnp7chQTFa4F4+A+orKvALHZseD0OO3bLhyUtMs8S3M6qtw5nyb/WWA0UyJvSsE6/emf +deAn3wfoEZ7Y4W067yGO12cvXQAvGHp8nffFCvFzJyxsFKaYLOSEwQlHdsBw1CX/ida 3m7dntTVqt3T/5NiRuIuqb748c+mWyZ/9ClVRqA2R9Ar70A68xbHD8K2iCvmmioApei4 B3BRVLpWKz33QinE0cSCCwS0LXD15XtVRz73yCaYoFuin5NtBuLZWKpxK61mv8lVJFKO I/8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x5pmzjoZiXuT0DHzxI2DxQ95Z5ycnNU6zzqPLmhAnlU=; b=LcRGkf7cxNltiWeylSuXhMDl3dzgWL3pKrXkiGVRdB1krOP3To+Do2f0GpB3VWpk9V GXO+F1/E0LF+uhAXyBcgZPuHajVYVBHPDNrOjs7yqKwH3omY/Tkzg4DjaiWc9vml9OTz JkgTWH8UO7xdZjpBBthBr87bBcpmZEwdU7yIvbXnkD1rhjKMtEmLh0yORi612RgBeVCI D6h7m+v3hsNUf/7LwlM4D05FnB9EEwIUuJTe2PQEtXPSiJYE+blPWvMUJDD58HtCi901 ni7ilSCR9oHyEh+jrkzyfaVbYs16YfRUrIh+eu6UgIvGLYKSJbixF0IJsNeXzHRQFB41 fTvg== X-Gm-Message-State: AJIora8x8W7DBKZXRGjBa7VnEyFx08l/jwoCXuMeLDGBwF6k6hm4cBAq 5M5Tpskbr1dTHVFAyjNHlVH4AMdPnkviQy1E X-Google-Smtp-Source: AGRyM1vZ/3IsA//wkv31dpOCNXq5uSHNfDa5RapeJAYCPEFo8Td8KHMEzwJ70BYPO4Kgj5+kSu2c2A== X-Received: by 2002:adf:f601:0:b0:219:f4e9:cc40 with SMTP id t1-20020adff601000000b00219f4e9cc40mr634217wrp.362.1655310406065; Wed, 15 Jun 2022 09:26:46 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r17-20020a05600c35d100b0039c8d181ac6sm3135772wmq.26.2022.06.15.09.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:26:45 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Jun 2022 18:26:00 +0200 Message-Id: <20220615162601.48619-3-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615162601.48619-1-dse@thaumatec.com> References: <20220615162601.48619-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] Documentation: Update code examples to use the Request::reuse() method 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: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" After introduction of reuse(), there is no need of manual request reconfiguration. Furthermore, current example code does not work anymore. --- Documentation/guides/application-developer.rst | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 6ab8b7e5..00bafb10 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -485,21 +485,7 @@ streams, and finally, queue the new capture request to the camera device: .. code:: cpp - request = camera->createRequest(); - if (!request) - { - std::cerr << "Can't create request" << std::endl; - return; - } - - for (auto it = buffers.begin(); it != buffers.end(); ++it) - { - Stream *stream = it->first; - FrameBuffer *buffer = it->second; - - request->addBuffer(stream, buffer); - } - + request->reuse(Request::ReuseBuffers); camera->queueRequest(request); Request queueing From patchwork Wed Jun 15 16:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16225 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 50E85BD161 for ; Wed, 15 Jun 2022 16:26:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75D036563B; Wed, 15 Jun 2022 18:26:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655310412; bh=Zz3mgoEdxlZ0YLtfx20Y4BEyNKgyBga+xVlO69YzjpM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=l5oYvxaqKcF0CxmIDXEWpcNj4AAHrUKdUFkjG5AKV3kiOkISGUBZayaUfUOuMbeyL dcPg/uk6ukdA3DJ3KW/EuDI2fxRvNsYeHE3rIR4Gml/rMd39+pL9dtFtERPn7tFEEf UlqFe8MFBrVfMwnyjQxRNBnycTunEsFyvxHArDIkBbFg2jTcEyO2Ydi1EGmh+Oa05Q txKbbM+u3FNo/HHs8uurgwTcPhmwB9lb6oGn9pxd1PEKi48TN/EX2qQGlhy6E5KYZX gZIYk2mtASms2io+Ums9OqPjJshLElUdlUoVV7osXSKpuNL4gMwluXGvKXq2nt5TcQ UkGVkjFmqg1Mw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CD1165631 for ; Wed, 15 Jun 2022 18:26:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="TIWBLOD2"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id m24so16055843wrb.10 for ; Wed, 15 Jun 2022 09:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aqQCb5uzLsNRQWZ/xnGq1V+ALWcNJVzZAg6ePoizt50=; b=TIWBLOD2bbIEEeSZQ9F4tnZU4rNGs/Pw2E9xFLJZ0qgRQww7wDKcdO4IDc6sx+AXCG nSfYAnXt2usclCSCKK0FXZkV+Y8Tlg1WG5IQfixnEZqxGEvaoWdu5ciW34n5VQhgu7Xb 17hSS7fkQ9OKSEkDtoX9IlM6RPYB9ckuh7gvAzU6yN7fdW5sopd5ncBZ6kXbmhPK6sR1 sMmzPYd7A8+HkwuzI30TSLp+hTjqpKpso73wThkCL+igYPaizg+97wyOx/O0r1BY4jqy Fx5ie97UkgS2lPFh8HP3jTFXfrxoZH9icpizQgjqtFR9cmIqBfucvHd9ev3LXctJr1tx 375w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aqQCb5uzLsNRQWZ/xnGq1V+ALWcNJVzZAg6ePoizt50=; b=K5zzOxIY2SWOG22NOR+Q6MOkwiva0Dy/dwsaupHVlVbgbGH+WCfozBnKcQ86ZbE1FV iTzEy+wjfCOjuDLCtXHWDZeCD8/VXJhkMB65qvLJudR0htlAL27bmAQxhl2C19p5Gja8 IAWOyvElU8Pfc9UGWeSp51X5BGFMTnw9YwCzbTIT6crGYCLT+COnZpz99et4OQfJUmmp 1THvzOJIZhMy5eIjizTAt5DafVXGWWiFOPxOSVP+zct5+szU6nfEdYDNAvel1t7f8Vd1 6qJEoFhUbEl38uxv3qNstVIx8DEO6cCr9qVbZ9QeBJZLGKiT4U2cu0BWLeH4ovzb6tBZ 49ow== X-Gm-Message-State: AJIora/AtrHmuy9B07ewq963hAIGe5jAUxf5zX9Firujef3+QZgZOqEU qpP8c7Jl1y5iLjH9QI33/gRY189uLRJC+49O X-Google-Smtp-Source: AGRyM1uP3yxbZFWBGV9EuwE5/5ownbikkUkzlwVApRepKORA/gd2z/Lv28gU6cIPYSUxJk/8g5fnrg== X-Received: by 2002:adf:dc81:0:b0:212:3a72:2f07 with SMTP id r1-20020adfdc81000000b002123a722f07mr603573wrj.714.1655310410943; Wed, 15 Jun 2022 09:26:50 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r17-20020a05600c35d100b0039c8d181ac6sm3135772wmq.26.2022.06.15.09.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:26:50 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Jun 2022 18:26:01 +0200 Message-Id: <20220615162601.48619-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220615162601.48619-1-dse@thaumatec.com> References: <20220615162601.48619-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] Documentation: Update the "Start an event loop" section 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: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Event loop was moved to be a part of CameraManager, so it is no longer a user responsibility to control the event dispatching. --- .../guides/application-developer.rst | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 00bafb10..97c032a5 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -27,10 +27,12 @@ defined names and types without the need of prefixing them. #include #include #include + #include #include using namespace libcamera; + using namespace std::chrono_literals; int main() { @@ -506,7 +508,7 @@ and queue all the previously created requests. for (std::unique_ptr &request : requests) camera->queueRequest(request.get()); -Start an event loop +Event loop ~~~~~~~~~~~~~~~~~~~ The libcamera library needs an event loop to monitor and dispatch events @@ -524,17 +526,17 @@ a notifier it is monitoring, it emits the notifier's notifiers' signals and emit application visible events, such as the ``Camera::bufferReady`` and ``Camera::requestCompleted`` signals. -The code below retrieves a reference to the system-wide event dispatcher and for -the a fixed duration of 3 seconds, processes all the events detected in the -system. +Event loop is handled internally by ``CameraManager`` instance in a separate +thread. ``CameraManager::start()`` creates a new thread and starts the event +loop processing. + +As the ``CameraManager`` was already started in our example, we need to prevent +the immediate termination of the application. The code below pauses the main +thread for 3 seconds, so that the event loop thread can process the requests. .. code:: cpp - EventDispatcher *dispatcher = cm->eventDispatcher(); - Timer timer; - timer.start(3000); - while (timer.isRunning()) - dispatcher->processEvents(); + std::this_thread::sleep_for(3000ms); Clean up and stop the application ---------------------------------