{"id":11955,"url":"https://patchwork.libcamera.org/api/patches/11955/?format=json","web_url":"https://patchwork.libcamera.org/patch/11955/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210415214812.234656-2-nfraprado@collabora.com>","date":"2021-04-15T21:48:11","name":"[libcamera-devel,RFC,1/2] lc-compliance: Make SimpleCapture::stop() idempotent","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e1dee7548aee73bd14f462966f62578d636c91c7","submitter":{"id":84,"url":"https://patchwork.libcamera.org/api/people/84/?format=json","name":"Nícolas F. R. A. Prado","email":"nfraprado@collabora.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11955/mbox/","series":[{"id":1937,"url":"https://patchwork.libcamera.org/api/series/1937/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1937","date":"2021-04-15T21:48:10","name":"Refactor lc-compliance using Catch2","version":1,"mbox":"https://patchwork.libcamera.org/series/1937/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11955/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11955/checks/","tags":{},"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 16E2CBD233\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Apr 2021 21:48:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D864668814;\n\tThu, 15 Apr 2021 23:48:54 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A82A8605AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Apr 2021 23:48:53 +0200 (CEST)","from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2978:77f9:56be:21f2:e14e])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nfraprado)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id BBED91F432E1;\n\tThu, 15 Apr 2021 22:48:51 +0100 (BST)"],"From":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 15 Apr 2021 18:48:11 -0300","Message-Id":"<20210415214812.234656-2-nfraprado@collabora.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210415214812.234656-1-nfraprado@collabora.com>","References":"<20210415214812.234656-1-nfraprado@collabora.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH 1/2] lc-compliance: Make\n\tSimpleCapture::stop() idempotent","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Make SimpleCapture::stop() be able to be called multiple times and at\nany point so that it can be called from the destructor and an assert\nfailure can return immeadiately.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n---\n src/lc-compliance/simple_capture.cpp | 12 +++++-------\n 1 file changed, 5 insertions(+), 7 deletions(-)","diff":"diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\nindex 0ff720bfd005..c20444aff9ba 100644\n--- a/src/lc-compliance/simple_capture.cpp\n+++ b/src/lc-compliance/simple_capture.cpp\n@@ -16,6 +16,7 @@ SimpleCapture::SimpleCapture(std::shared_ptr<Camera> camera)\n \n SimpleCapture::~SimpleCapture()\n {\n+\tstop();\n }\n \n Results::Result SimpleCapture::configure(StreamRole role)\n@@ -51,12 +52,16 @@ Results::Result SimpleCapture::start()\n \n Results::Result SimpleCapture::stop()\n {\n+\tif (!config_)\n+\t\treturn;\n \tStream *stream = config_->at(0).stream();\n \n \tcamera_->stop();\n \n \tcamera_->requestCompleted.disconnect(this, &SimpleCapture::requestComplete);\n \n+\tif (!allocator_->allocated())\n+\t\treturn;\n \tallocator_->free(stream);\n \n \treturn { Results::Pass, \"Stopped camera\" };\n@@ -82,7 +87,6 @@ Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests)\n \tif (buffers.size() > numRequests) {\n \t\t/* Cache buffers.size() before we destroy it in stop() */\n \t\tint buffers_size = buffers.size();\n-\t\tstop();\n \n \t\treturn { Results::Skip, \"Camera needs \" + std::to_string(buffers_size)\n \t\t\t+ \" requests, can't test only \" + std::to_string(numRequests) };\n@@ -97,17 +101,14 @@ Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests)\n \tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers) {\n \t\tstd::unique_ptr<Request> request = camera_->createRequest();\n \t\tif (!request) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Can't create request\" };\n \t\t}\n \n \t\tif (request->addBuffer(stream, buffer.get())) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Can't set buffer for request\" };\n \t\t}\n \n \t\tif (queueRequest(request.get()) < 0) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Failed to queue request\" };\n \t\t}\n \n@@ -174,17 +175,14 @@ Results::Result SimpleCaptureUnbalanced::capture(unsigned int numRequests)\n \tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers) {\n \t\tstd::unique_ptr<Request> request = camera_->createRequest();\n \t\tif (!request) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Can't create request\" };\n \t\t}\n \n \t\tif (request->addBuffer(stream, buffer.get())) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Can't set buffer for request\" };\n \t\t}\n \n \t\tif (camera_->queueRequest(request.get()) < 0) {\n-\t\t\tstop();\n \t\t\treturn { Results::Fail, \"Failed to queue request\" };\n \t\t}\n \n","prefixes":["libcamera-devel","RFC","1/2"]}