[{"id":18453,"web_url":"https://patchwork.libcamera.org/comment/18453/","msgid":"<YQcHCilYnGzx5sf7@pendragon.ideasonboard.com>","date":"2021-08-01T20:41:46","subject":"Re: [libcamera-devel] [PATCH v7 03/11] lc-compliance: Move buffer\n\tallocation to separate function","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nícolas,\n\nOn Thu, Jul 22, 2021 at 08:28:43PM -0300, Nícolas F. R. A. Prado wrote:\n> Move buffer allocation to its own function and with a count argument so\n> tests can specify how many buffers to allocate.\n> \n> Also add an overloaded function with no arguments and that allocates\n> MinNumRequests buffers for easier use by current tests.\n\nIt's now called MinimumRequests.\n\n> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> ---\n> \n> No changes in v7\n> \n> No changes in v6\n> \n> Added in v5\n> \n>  src/lc-compliance/capture_test.cpp   |  8 +++++++-\n>  src/lc-compliance/simple_capture.cpp | 15 +++++++++++----\n>  src/lc-compliance/simple_capture.h   |  2 ++\n>  3 files changed, 20 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp\n> index 52578207c11f..6439cbd88f8e 100644\n> --- a/src/lc-compliance/capture_test.cpp\n> +++ b/src/lc-compliance/capture_test.cpp\n> @@ -80,6 +80,8 @@ TEST_P(SingleStream, Capture)\n>  \n>  \tcapture.configure(role);\n>  \n> +\tcapture.allocateBuffers();\n> +\n>  \tcapture.capture(numRequests);\n>  }\n>  \n> @@ -99,8 +101,10 @@ TEST_P(SingleStream, CaptureStartStop)\n>  \n>  \tcapture.configure(role);\n>  \n> -\tfor (unsigned int starts = 0; starts < numRepeats; starts++)\n> +\tfor (unsigned int starts = 0; starts < numRepeats; starts++) {\n> +\t\tcapture.allocateBuffers();\n>  \t\tcapture.capture(numRequests);\n> +\t}\n>  }\n>  \n>  /*\n> @@ -118,6 +122,8 @@ TEST_P(SingleStream, UnbalancedStop)\n>  \n>  \tcapture.configure(role);\n>  \n> +\tcapture.allocateBuffers();\n> +\n>  \tcapture.capture(numRequests);\n>  }\n>  \n> diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\n> index 6444203547be..8683d9050806 100644\n> --- a/src/lc-compliance/simple_capture.cpp\n> +++ b/src/lc-compliance/simple_capture.cpp\n> @@ -44,15 +44,22 @@ void SimpleCapture::configure(StreamRole role)\n>  \t}\n>  }\n>  \n> -void SimpleCapture::start()\n> +void SimpleCapture::allocateBuffers()\n> +{\n> +\tallocateBuffers(camera_->properties().get(properties::MinimumRequests));\n> +}\n> +\n> +void SimpleCapture::allocateBuffers(unsigned int count)\n>  {\n> -\tunsigned int bufferCount = camera_->properties().get(properties::MinNumRequests);\n>  \tStream *stream = config_->at(0).stream();\n> -\tint count = allocator_->allocate(stream, bufferCount);\n> +\tint allocatedCount = allocator_->allocate(stream, count);\n\nYou could also declare a single function with a default value for the\ncount parameter\n\n\tvoid allocateBuffers(unsigned int count = 0);\n\nand have\n\n\tif (!count)\n\t\tcount = camera_->properties().get(properties::MinimumRequests);\n\nhere.\n\n>  \n>  \tASSERT_GE(count, 0) << \"Failed to allocate buffers\";\n> -\tEXPECT_EQ(static_cast<unsigned int>(count), bufferCount) << \"Allocated less buffers than expected\";\n> +\tEXPECT_EQ(static_cast<unsigned int>(allocatedCount), count) << \"Allocated less buffers than expected\";\n> +}\n>  \n> +void SimpleCapture::start()\n> +{\n>  \tcamera_->requestCompleted.connect(this, &SimpleCapture::requestComplete);\n>  \n>  \tASSERT_EQ(camera_->start(), 0) << \"Failed to start camera\";\n> diff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\n> index 100ffd6637ad..1a1e874a528c 100644\n> --- a/src/lc-compliance/simple_capture.h\n> +++ b/src/lc-compliance/simple_capture.h\n> @@ -17,6 +17,8 @@ class SimpleCapture\n>  {\n>  public:\n>  \tvoid configure(libcamera::StreamRole role);\n> +\tvoid allocateBuffers();\n> +\tvoid allocateBuffers(unsigned int count);\n>  \n>  protected:\n>  \tSimpleCapture(std::shared_ptr<libcamera::Camera> camera);","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 22105C3232\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  1 Aug 2021 20:41:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8257F687B6;\n\tSun,  1 Aug 2021 22:41:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8867D687B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  1 Aug 2021 22:41:56 +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 02B3487C;\n\tSun,  1 Aug 2021 22:41:55 +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=\"uCWAhPtb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627850516;\n\tbh=hwVQqJY9mZTG4a+ehccTu1e3AdLtmhvY/cyV33ChuGs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uCWAhPtbdct7DEBJH31Fz+WvF1ppzc3hDgb8n0WdrXLswGSsreWtdGgMs098jBUKp\n\tlE4Q6hsTpPlCc47r6xnJcO7cXJHrTkIlTDQXFuGoArOzzDNMPq34/Kk1Q0JbJtuzgX\n\t7vuKNd6J26LXs5oYj8w0u5UIYdpyQbh5BuDx9bkg=","Date":"Sun, 1 Aug 2021 23:41:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4=?= Prado <nfraprado@collabora.com>","Message-ID":"<YQcHCilYnGzx5sf7@pendragon.ideasonboard.com>","References":"<20210722232851.747614-1-nfraprado@collabora.com>\n\t<20210722232851.747614-4-nfraprado@collabora.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210722232851.747614-4-nfraprado@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH v7 03/11] lc-compliance: Move buffer\n\tallocation to separate function","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, kernel@collabora.com, =?utf-8?q?A?=\n\t=?utf-8?b?bmRyw6k=?= Almeida <andrealmeid@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]