Patch Detail
Show a patch.
GET /api/patches/240/?format=api
{ "id": 240, "url": "https://patchwork.libcamera.org/api/patches/240/?format=api", "web_url": "https://patchwork.libcamera.org/patch/240/", "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": "<20190115151849.1547-9-laurent.pinchart@ideasonboard.com>", "date": "2019-01-15T15:18:49", "name": "[libcamera-devel,v2,8/8] libcamera: camera_manager: Turn enumerator into a unique_ptr<>", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "831ca8d6d69292fab9a4b9604c7995da5f171f76", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/240/mbox/", "series": [ { "id": 81, "url": "https://patchwork.libcamera.org/api/series/81/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=81", "date": "2019-01-15T15:18:41", "name": "Pipeline handler refactoring and assorted improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/81/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/240/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/240/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF5F860C8A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jan 2019 16:18:55 +0100 (CET)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77C2E4F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jan 2019 16:18:55 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1547565535;\n\tbh=wIyEthRVn+dkk80COo3O7gLrLmoXEdkapwc5+9KikkM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=M1cStOQC2WpS7oAOPF5zPQ/FZMis6Rx6DZV0mrl4b9txmGXlotDdkhdKMZkU3EqvN\n\tojJhsaLJcQfGFEfwDjuiLHcSu9Z9tQB7VwTASuTP9XgEMayU9VBPHNRK9cI9PoRUd+\n\tYVmigf9ARQyWF5VGcNEv7IPtc49qAWirQl0rhrjo=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 15 Jan 2019 17:18:49 +0200", "Message-Id": "<20190115151849.1547-9-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190115151849.1547-1-laurent.pinchart@ideasonboard.com>", "References": "<20190115151849.1547-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 8/8] libcamera: camera_manager: Turn\n\tenumerator into a unique_ptr<>", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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>", "X-List-Received-Date": "Tue, 15 Jan 2019 15:18:56 -0000" }, "content": "Convey the fact that the CameraManager class owns the DeviceEnumerator\ninstance it creates by using std::unique_ptr<> to store the pointer.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/camera_manager.h | 3 ++-\n src/libcamera/camera_manager.cpp | 8 ++------\n src/libcamera/device_enumerator.cpp | 9 ++++-----\n src/libcamera/include/device_enumerator.h | 3 ++-\n 4 files changed, 10 insertions(+), 13 deletions(-)", "diff": "diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\nindex 15e7c162032a..6cfcba3c3933 100644\n--- a/include/libcamera/camera_manager.h\n+++ b/include/libcamera/camera_manager.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_CAMERA_MANAGER_H__\n #define __LIBCAMERA_CAMERA_MANAGER_H__\n \n+#include <memory>\n #include <string>\n #include <vector>\n \n@@ -37,7 +38,7 @@ private:\n \tvoid operator=(const CameraManager &) = delete;\n \t~CameraManager();\n \n-\tDeviceEnumerator *enumerator_;\n+\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n \tstd::vector<PipelineHandler *> pipes_;\n \n \tEventDispatcher *dispatcher_;\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex a17bf3d13a04..ae5542bc332d 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -73,7 +73,6 @@ CameraManager::~CameraManager()\n */\n int CameraManager::start()\n {\n-\n \tif (enumerator_)\n \t\treturn -ENODEV;\n \n@@ -95,7 +94,7 @@ int CameraManager::start()\n \t\t */\n \t\twhile (1) {\n \t\t\tPipelineHandler *pipe = factory->create();\n-\t\t\tif (!pipe->match(enumerator_)) {\n+\t\t\tif (!pipe->match(enumerator_.get())) {\n \t\t\t\tdelete pipe;\n \t\t\t\tbreak;\n \t\t\t}\n@@ -130,10 +129,7 @@ void CameraManager::stop()\n \n \tpipes_.clear();\n \n-\tif (enumerator_)\n-\t\tdelete enumerator_;\n-\n-\tenumerator_ = nullptr;\n+\tenumerator_.reset(nullptr);\n }\n \n /**\ndiff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex 18d7e86843e8..55c510e3b79a 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -14,6 +14,7 @@\n #include \"device_enumerator.h\"\n #include \"log.h\"\n #include \"media_device.h\"\n+#include \"utils.h\"\n \n /**\n * \\file device_enumerator.h\n@@ -128,20 +129,18 @@ bool DeviceMatch::match(const MediaDevice *device) const\n * \\return A pointer to the newly created device enumerator on success, or\n * nullptr if an error occurs\n */\n-DeviceEnumerator *DeviceEnumerator::create()\n+std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()\n {\n-\tDeviceEnumerator *enumerator;\n+\tstd::unique_ptr<DeviceEnumerator> enumerator;\n \n \t/**\n \t * \\todo Add compile time checks to only try udev enumerator if libudev\n \t * is available.\n \t */\n-\tenumerator = new DeviceEnumeratorUdev();\n+\tenumerator = utils::make_unique<DeviceEnumeratorUdev>();\n \tif (!enumerator->init())\n \t\treturn enumerator;\n \n-\tdelete enumerator;\n-\n \t/*\n \t * Either udev is not available or udev initialization failed. Fall back\n \t * on the sysfs enumerator.\ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nindex b68c815827dd..c5541c5f8d12 100644\n--- a/src/libcamera/include/device_enumerator.h\n+++ b/src/libcamera/include/device_enumerator.h\n@@ -8,6 +8,7 @@\n #define __LIBCAMERA_DEVICE_ENUMERATOR_H__\n \n #include <map>\n+#include <memory>\n #include <string>\n #include <vector>\n \n@@ -34,7 +35,7 @@ private:\n class DeviceEnumerator\n {\n public:\n-\tstatic DeviceEnumerator *create();\n+\tstatic std::unique_ptr<DeviceEnumerator> create();\n \n \tvirtual ~DeviceEnumerator();\n \n", "prefixes": [ "libcamera-devel", "v2", "8/8" ] }