Patch Detail
Show a patch.
GET /api/patches/12102/?format=api
{ "id": 12102, "url": "https://patchwork.libcamera.org/api/patches/12102/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12102/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210423142412.460460-1-nfraprado@collabora.com>", "date": "2021-04-23T14:24:12", "name": "[libcamera-devel] libcamera: camera: Make stop() idempotent", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "12f6e700dab3a0258a31ae452eaf223af205165f", "submitter": { "id": 84, "url": "https://patchwork.libcamera.org/api/people/84/?format=api", "name": "Nícolas F. R. A. Prado", "email": "nfraprado@collabora.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12102/mbox/", "series": [ { "id": 1972, "url": "https://patchwork.libcamera.org/api/series/1972/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1972", "date": "2021-04-23T14:24:12", "name": "[libcamera-devel] libcamera: camera: Make stop() idempotent", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1972/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12102/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12102/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 BDFB4BDB15\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Apr 2021 14:25:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 310B86887C;\n\tFri, 23 Apr 2021 16:25:13 +0200 (CEST)", "from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F78F6885A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Apr 2021 16:25:11 +0200 (CEST)", "from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nfraprado) with ESMTPSA id 841B21F43CDB" ], "From": "=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 23 Apr 2021 11:24:12 -0300", "Message-Id": "<20210423142412.460460-1-nfraprado@collabora.com>", "X-Mailer": "git-send-email 2.31.1", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH] libcamera: camera: Make 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>", "Cc": "kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>", "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 Camera::stop() idempotent so that it can be called in any state and\nconsecutive times. When called in any state other than CameraRunning, it\nis a no-op. This simplifies the cleanup path for applications.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n---\nThis will be used to simplify the cleanup path in lc-compliance without having\nerror messages [1].\n\nAlso, I'm not sure if I should add the silent parameter to the other\nisAccessAllowed variant as well. It would make sense for consistency's sake, but\nit's not needed currently.\n\n[1] https://lists.libcamera.org/pipermail/libcamera-devel/2021-April/019703.html\n\n src/libcamera/camera.cpp | 29 ++++++++++++++++++-----------\n 1 file changed, 18 insertions(+), 11 deletions(-)", "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 763f3b9926fd..baffdafc8146 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -350,7 +350,7 @@ public:\n \tint isAccessAllowed(State state, bool allowDisconnected = false,\n \t\t\t const char *from = __builtin_FUNCTION()) const;\n \tint isAccessAllowed(State low, State high,\n-\t\t\t bool allowDisconnected = false,\n+\t\t\t bool allowDisconnected = false, bool silent = false,\n \t\t\t const char *from = __builtin_FUNCTION()) const;\n \n \tvoid disconnect();\n@@ -408,7 +408,7 @@ int Camera::Private::isAccessAllowed(State state, bool allowDisconnected,\n }\n \n int Camera::Private::isAccessAllowed(State low, State high,\n-\t\t\t\t bool allowDisconnected,\n+\t\t\t\t bool allowDisconnected, bool silent,\n \t\t\t\t const char *from) const\n {\n \tif (!allowDisconnected && disconnected_)\n@@ -421,11 +421,12 @@ int Camera::Private::isAccessAllowed(State low, State high,\n \tASSERT(static_cast<unsigned int>(low) < std::size(camera_state_names) &&\n \t static_cast<unsigned int>(high) < std::size(camera_state_names));\n \n-\tLOG(Camera, Error) << \"Camera in \" << camera_state_names[currentState]\n-\t\t\t << \" state trying \" << from\n-\t\t\t << \"() requiring state between \"\n-\t\t\t << camera_state_names[low] << \" and \"\n-\t\t\t << camera_state_names[high];\n+\tif (!silent)\n+\t\tLOG(Camera, Error) << \"Camera in \" << camera_state_names[currentState]\n+\t\t\t\t << \" state trying \" << from\n+\t\t\t\t << \"() requiring state between \"\n+\t\t\t\t << camera_state_names[low] << \" and \"\n+\t\t\t\t << camera_state_names[high];\n \n \treturn -EACCES;\n }\n@@ -1061,9 +1062,10 @@ int Camera::start(const ControlList *controls)\n * This method stops capturing and processing requests immediately. All pending\n * requests are cancelled and complete synchronously in an error state.\n *\n- * \\context This function may only be called when the camera is in the Running\n- * state as defined in \\ref camera_operation, and shall be synchronized by the\n- * caller with other functions that affect the camera state.\n+ * \\context This function may be called even if the camera isn't in the Running\n+ * state as defined in \\ref camera_operation, in which cases it is a no-op. It\n+ * shall be synchronized by the caller with other functions that affect the\n+ * camera state.\n *\n * \\return 0 on success or a negative error code otherwise\n * \\retval -ENODEV The camera has been disconnected from the system\n@@ -1073,7 +1075,12 @@ int Camera::stop()\n {\n \tPrivate *const d = LIBCAMERA_D_PTR();\n \n-\tint ret = d->isAccessAllowed(Private::CameraRunning);\n+\tint ret = d->isAccessAllowed(Private::CameraAvailable,\n+\t\t\tPrivate::CameraStopping, false, true);\n+\tif (!ret)\n+\t\treturn 0;\n+\n+\tret = d->isAccessAllowed(Private::CameraRunning);\n \tif (ret < 0)\n \t\treturn ret;\n \n", "prefixes": [ "libcamera-devel" ] }