Patch Detail
Show a patch.
GET /api/patches/11677/?format=api
{ "id": 11677, "url": "https://patchwork.libcamera.org/api/patches/11677/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11677/", "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-2-hiroh@chromium.org>", "date": "2021-03-24T07:07:50", "name": "[libcamera-devel,v2,1/8] android: CameraHalManager: Hold CameraDevice with std::unique_ptr", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "bc45799248edad2f277cbf89cc39b06f89fa9b51", "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/11677/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/11677/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11677/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 8827BC32E7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Mar 2021 07:08:16 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D04568D6F;\n\tWed, 24 Mar 2021 08:08:16 +0100 (CET)", "from mail-pf1-x436.google.com (mail-pf1-x436.google.com\n\t[IPv6:2607:f8b0:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 59CA668D62\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 08:08:12 +0100 (CET)", "by mail-pf1-x436.google.com with SMTP id y200so16653789pfb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 00:08:11 -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.04\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 24 Mar 2021 00:08:05 -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=\"gATmTxVG\"; 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=FBIId1IlESikLmSIrXc64sNJ/ca/awir3F5edcNGkIU=;\n\tb=gATmTxVGog/JFGV2sXXRidCil2jEJP3VP2153GVVnN+Q17ZsbKdi+Kf7yjs9KqNsvX\n\t5PB1vlgtzSfPifuAbFKIoflZDGxjwUl+0Yk99Afrtbb8VXYTJJ+c8MbqeqR0+bq9re1K\n\tnwTPYjQp8FvBHLxCs5VS35izCTZX2tJ3koEPA=", "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=FBIId1IlESikLmSIrXc64sNJ/ca/awir3F5edcNGkIU=;\n\tb=CRvOfHm7c726O/YAO8pa/66cXWSECArY1Hk2X7FKy1tOm4NKPQNYpj9j/kRFmLRq8U\n\t07t/V82TI9kryR8n/yHMLA5PqI9hHSNc/gWcqx0VEx7EX94KgELDYb1h/Tdb1G2RjeQl\n\t5sa0uQSXHpE2Aa6dBGnBXAgD7iPzoYH5L91w5uGx6vx3/kfabfa7EalmVFdp9HRP6W4w\n\tDg8ttmmVyq+OMsAN5uoXHsllAmsl9rOmOeUVwiek59aRZX+bPU08iuwsma8xKQPet4Z7\n\tOYxuQhInDS6fVws+opHJ3uNNGuudUjmznBdnYRFjNrlIA4HZiAQm0KaA7Rp4rYHAGZKY\n\tOwLw==", "X-Gm-Message-State": "AOAM533vE7D/zwaI1jr0X6ymrk4XcIBON/lmLMeu1OJly7/rGxG0ZpEN\n\tCA7A3dcAL+O8lymdn167RAo4epe9x6zvIQ==", "X-Google-Smtp-Source": "ABdhPJwg8ArejE6C3+lSeOkLDFnZYm0kZBxdJYvrkQP4SWHMDZM0ymwiLtoY4fQBmq5VerBMTXRAVg==", "X-Received": "by 2002:a63:520e:: with SMTP id\n\tg14mr1816026pgb.350.1616569686220; \n\tWed, 24 Mar 2021 00:08:06 -0700 (PDT)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 24 Mar 2021 16:07:50 +0900", "Message-Id": "<20210324070757.3530377-2-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 1/8] android: CameraHalManager: Hold\n\tCameraDevice 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": "CameraDevice is owned by CameraHalManager. The ownership of the\nobject is not shared with other classes. So CameraHalManager\nshould manage CameraDevice with 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 | 5 ++---\n src/android/camera_device.h | 2 +-\n src/android/camera_hal_manager.cpp | 10 ++++------\n src/android/camera_hal_manager.h | 2 +-\n 4 files changed, 8 insertions(+), 11 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 72a89258..d0955de7 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -350,11 +350,10 @@ CameraDevice::~CameraDevice()\n \t\tdelete it.second;\n }\n\n-std::shared_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n+std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n \t\t\t\t\t\t const std::shared_ptr<Camera> &cam)\n {\n-\tCameraDevice *camera = new CameraDevice(id, cam);\n-\treturn std::shared_ptr<CameraDevice>(camera);\n+\treturn std::unique_ptr<CameraDevice>(new CameraDevice(id, cam));\n }\n\n /*\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 823d561c..8be7f305 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -32,7 +32,7 @@\n class CameraDevice : protected libcamera::Loggable\n {\n public:\n-\tstatic std::shared_ptr<CameraDevice> create(unsigned int id,\n+\tstatic std::unique_ptr<CameraDevice> create(unsigned int id,\n \t\t\t\t\t\t const std::shared_ptr<libcamera::Camera> &cam);\n \t~CameraDevice();\n\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex 189eda2b..b3c85406 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -36,8 +36,6 @@ CameraHalManager::CameraHalManager()\n\n CameraHalManager::~CameraHalManager()\n {\n-\tcameras_.clear();\n-\n \tif (cameraManager_) {\n \t\tcameraManager_->stop();\n \t\tdelete cameraManager_;\n@@ -124,7 +122,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n \t}\n\n \t/* Create a CameraDevice instance to wrap the libcamera Camera. */\n-\tstd::shared_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam));\n+\tstd::unique_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam));\n \tint ret = camera->initialize();\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to initialize camera: \" << cam->id();\n@@ -154,7 +152,7 @@ void CameraHalManager::cameraRemoved(std::shared_ptr<Camera> cam)\n \tMutexLocker locker(mutex_);\n\n \tauto iter = std::find_if(cameras_.begin(), cameras_.end(),\n-\t\t\t\t [&cam](std::shared_ptr<CameraDevice> &camera) {\n+\t\t\t\t [&cam](const std::unique_ptr<CameraDevice> &camera) {\n \t\t\t\t\t return cam == camera->camera();\n \t\t\t\t });\n \tif (iter == cameras_.end())\n@@ -191,7 +189,7 @@ int32_t CameraHalManager::cameraLocation(const Camera *cam)\n CameraDevice *CameraHalManager::cameraDeviceFromHalId(unsigned int id)\n {\n \tauto iter = std::find_if(cameras_.begin(), cameras_.end(),\n-\t\t\t\t [id](std::shared_ptr<CameraDevice> &camera) {\n+\t\t\t\t [id](const std::unique_ptr<CameraDevice> &camera) {\n \t\t\t\t\t return camera->id() == id;\n \t\t\t\t });\n \tif (iter == cameras_.end())\n@@ -243,7 +241,7 @@ void CameraHalManager::setCallbacks(const camera_module_callbacks_t *callbacks)\n \t * Internal cameras are already assumed to be present at module load\n \t * time by the Android framework.\n \t */\n-\tfor (std::shared_ptr<CameraDevice> &camera : cameras_) {\n+\tfor (const std::unique_ptr<CameraDevice> &camera : cameras_) {\n \t\tunsigned int id = camera->id();\n \t\tif (id >= firstExternalCameraId_)\n \t\t\tcallbacks_->camera_device_status_change(callbacks_, id,\ndiff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex a91decc7..65bb3554 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -50,7 +50,7 @@ private:\n \tlibcamera::CameraManager *cameraManager_;\n\n \tconst camera_module_callbacks_t *callbacks_;\n-\tstd::vector<std::shared_ptr<CameraDevice>> cameras_;\n+\tstd::vector<std::unique_ptr<CameraDevice>> cameras_;\n \tstd::map<std::string, unsigned int> cameraIdsMap_;\n \tMutex mutex_;\n\n", "prefixes": [ "libcamera-devel", "v2", "1/8" ] }