Patch Detail
Show a patch.
GET /api/patches/11683/?format=api
{ "id": 11683, "url": "https://patchwork.libcamera.org/api/patches/11683/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11683/", "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": "<20210324070757.3530377-9-hiroh@chromium.org>", "date": "2021-03-24T07:07:57", "name": "[libcamera-devel,v2,8/8] android: CameraDevice: Manage requestTemplates_ with std::unique_ptr", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "cbc72f35b8a652b28849fd601fb3d4943db31c51", "submitter": { "id": 63, "url": "https://patchwork.libcamera.org/api/people/63/?format=api", "name": "Hirokazu Honda", "email": "hiroh@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/11683/mbox/", "series": [ { "id": 1825, "url": "https://patchwork.libcamera.org/api/series/1825/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1825", "date": "2021-03-24T07:07:51", "name": "Improve pointer types in android HAL adaptation layer", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1825/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11683/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11683/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 D70A0C32E7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Mar 2021 07:08:26 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 964D968D63;\n\tWed, 24 Mar 2021 08:08:26 +0100 (CET)", "from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com\n\t[IPv6:2607:f8b0:4864:20::102f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A36BC68D58\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 08:08:24 +0100 (CET)", "by mail-pj1-x102f.google.com with SMTP id bt4so11231228pjb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 00:08:24 -0700 (PDT)", "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:7c07:24cd:c637:7fab])\n\tby smtp.gmail.com with ESMTPSA id\n\te63sm1246860pfe.208.2021.03.24.00.08.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 24 Mar 2021 00:08:17 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Mrq5NQWB\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=CZ/yhheXZdNsy75ODPaUnOnvm2NuTPUwsZaJGHiRGDI=;\n\tb=Mrq5NQWB6cRA321dPaeC2TWVu/2qNuait/NR8RPExpyPZfYxqoc9MbB+GgSwg8UwN9\n\tRYpYVdwQCyvSDxQhwNJCc0FZsHqNDvTbVlCwx45yBxXCAbwcFXVm+obnf15RZ4flLyFL\n\tGqW++G5XU9l4Hus/GTdT1Ky+pMh+6RXVr3peU=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=CZ/yhheXZdNsy75ODPaUnOnvm2NuTPUwsZaJGHiRGDI=;\n\tb=OqnL6gy4yyh7benvsfCkOHz/SLYHZbdLyCJyK2EP9ebQF1R0WJRCNvxEM16Bei1+3e\n\t6HDfef2i3/utolQX0g7T7OtAduvSdoR+/IRQoHwEpqa0OZdAY7P65zdRgxmeAHuB97Ur\n\tErKlHNdM0OF/Lf8Iu45HlocMWo4AG21AgZPJ1WmwnTZlfdgUACV0xVAo4MheZg7KcnS9\n\tIjpTklHxePw8Oefuok7M56/OSc8X89kYylvRC08wCC2bjgmr5WlA/2iCzaQ/3xKStvWg\n\t/Mz41qOdaAd9hAoaXM1mQ9xX/f8tfQZ/pZG5B+7J5LQdBrgnIze2JYWvY6cSr80tsLaq\n\tzc+A==", "X-Gm-Message-State": "AOAM533dPIEP6QwuNRbaGWHYVHKLGzuNC7fOfb6IW6uzNRdaWamAsX0V\n\tusKeU1pjMESaHaDSQPIVGb5nSd0cWC/WIg==", "X-Google-Smtp-Source": "ABdhPJxXhsnwIqFiYbkBBll/L/NkjiVDhWNJelEJbttuc0sdzekGB26t52JtmXFgPLuhpWPPxQLZdg==", "X-Received": "by 2002:a17:90b:1296:: with SMTP id\n\tfw22mr1975418pjb.93.1616569697466; \n\tWed, 24 Mar 2021 00:08:17 -0700 (PDT)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 24 Mar 2021 16:07:57 +0900", "Message-Id": "<20210324070757.3530377-9-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.31.0.291.g576ba9dcdaf-goog", "In-Reply-To": "<20210324070757.3530377-1-hiroh@chromium.org>", "References": "<20210324070757.3530377-1-hiroh@chromium.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 8/8] android: CameraDevice: Manage\n\trequestTemplates_ with std::unique_ptr", "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=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "CameraMetadata stored in requestTemplates_ in CameraDevice is\nnot necessary to be a raw pointer. This reduces the manual\nnew/delete code by changing the type to std::unique_ptr.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.cpp | 22 ++++++++--------------\n src/android/camera_device.h | 6 +++---\n 2 files changed, 11 insertions(+), 17 deletions(-)\n\n--\n2.31.0.291.g576ba9dcdaf-goog", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 8fdcb85a..5fbf6f82 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -338,11 +338,7 @@ CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)\n \t}\n }\n\n-CameraDevice::~CameraDevice()\n-{\n-\tfor (auto &it : requestTemplates_)\n-\t\tdelete it.second;\n-}\n+CameraDevice::~CameraDevice() = default;\n\n std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n \t\t\t\t\t\t std::shared_ptr<Camera> cam)\n@@ -1358,15 +1354,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \treturn staticMetadata_->get();\n }\n\n-CameraMetadata *CameraDevice::requestTemplatePreview()\n+std::unique_ptr<CameraMetadata> CameraDevice::requestTemplatePreview()\n {\n \t/*\n \t * \\todo Keep this in sync with the actual number of entries.\n \t * Currently: 20 entries, 35 bytes\n \t */\n-\tCameraMetadata *requestTemplate = new CameraMetadata(21, 36);\n+\tauto requestTemplate = std::make_unique<CameraMetadata>(21, 36);\n \tif (!requestTemplate->isValid()) {\n-\t\tdelete requestTemplate;\n \t\treturn nullptr;\n \t}\n\n@@ -1454,9 +1449,9 @@ CameraMetadata *CameraDevice::requestTemplatePreview()\n \treturn requestTemplate;\n }\n\n-CameraMetadata *CameraDevice::requestTemplateVideo()\n+std::unique_ptr<CameraMetadata> CameraDevice::requestTemplateVideo()\n {\n-\tCameraMetadata *previewTemplate = requestTemplatePreview();\n+\tstd::unique_ptr<CameraMetadata> previewTemplate = requestTemplatePreview();\n \tif (!previewTemplate)\n \t\treturn nullptr;\n\n@@ -1488,7 +1483,7 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n \t\treturn it->second->get();\n\n \t/* Use the capture intent matching the requested template type. */\n-\tCameraMetadata *requestTemplate;\n+\tstd::unique_ptr<CameraMetadata> requestTemplate;\n \tuint8_t captureIntent;\n \tswitch (type) {\n \tcase CAMERA3_TEMPLATE_PREVIEW:\n@@ -1521,15 +1516,14 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)\n\n \tif (!requestTemplate || !requestTemplate->isValid()) {\n \t\tLOG(HAL, Error) << \"Failed to construct request template\";\n-\t\tdelete requestTemplate;\n \t\treturn nullptr;\n \t}\n\n \trequestTemplate->updateEntry(ANDROID_CONTROL_CAPTURE_INTENT,\n \t\t\t\t &captureIntent, 1);\n\n-\trequestTemplates_[type] = requestTemplate;\n-\treturn requestTemplate->get();\n+\trequestTemplates_[type] = std::move(requestTemplate);\n+\treturn requestTemplates_[type]->get();\n }\n\n PixelFormat CameraDevice::toPixelFormat(int format) const\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex cea82b24..09c395ff 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -97,8 +97,8 @@ private:\n \tlibcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);\n \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n-\tCameraMetadata *requestTemplatePreview();\n-\tCameraMetadata *requestTemplateVideo();\n+\tstd::unique_ptr<CameraMetadata> requestTemplatePreview();\n+\tstd::unique_ptr<CameraMetadata> requestTemplateVideo();\n \tlibcamera::PixelFormat toPixelFormat(int format) const;\n \tint processControls(Camera3RequestDescriptor *descriptor);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n@@ -114,7 +114,7 @@ private:\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n\n \tstd::unique_ptr<CameraMetadata> staticMetadata_;\n-\tstd::map<unsigned int, const CameraMetadata *> requestTemplates_;\n+\tstd::map<unsigned int, std::unique_ptr<CameraMetadata>> requestTemplates_;\n \tconst camera3_callback_ops_t *callbacks_;\n\n \tstd::vector<Camera3StreamConfiguration> streamConfigurations_;\n", "prefixes": [ "libcamera-devel", "v2", "8/8" ] }