{"id":10659,"url":"https://patchwork.libcamera.org/api/patches/10659/?format=json","web_url":"https://patchwork.libcamera.org/patch/10659/","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":"<20201212185116.29611-3-laurent.pinchart@ideasonboard.com>","date":"2020-12-12T18:51:15","name":"[libcamera-devel,2/3] libcamera: pipeline: vimc: Use V4L2*::fromEntityName() where possible","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d1fe137b9c9b3b3976eb6fc9c7fd703357704966","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/10659/mbox/","series":[{"id":1531,"url":"https://patchwork.libcamera.org/api/series/1531/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1531","date":"2020-12-12T18:51:14","name":"libcamera: Fix leaks and simplify object management with std::unique_ptr<>","version":1,"mbox":"https://patchwork.libcamera.org/series/1531/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10659/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10659/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 CB19EBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 12 Dec 2020 18:51:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5448860353;\n\tSat, 12 Dec 2020 19:51:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CA37960342\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Dec 2020 19:51:27 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 202AE2CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Dec 2020 19:51:27 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Lf3OgXtY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1607799087;\n\tbh=9/JPiRvpjeMNUTO6PuHYz/UK67oHNs9xi4GJvuOH0Jc=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Lf3OgXtYNBMFxIct40s34XXLuRDytjhHJzaGTfMbVBNQBocvWh2+h2ZZZZDOwfTH0\n\tadtMmliJZROMXKlyGrpJvp8kwoO2q+fJZVyrjn1ScVDkYVuaqI0CH/d5F9TkeFBMBC\n\tUL/e3QvcwZ0gpCjttXVUexUz9OVF+OnGbw1+gAFQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 12 Dec 2020 20:51:15 +0200","Message-Id":"<20201212185116.29611-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201212185116.29611-1-laurent.pinchart@ideasonboard.com>","References":"<20201212185116.29611-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 2/3] libcamera: pipeline: vimc: Use\n\tV4L2*::fromEntityName() where possible","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":"Replace manual construction of V4L2VideoDevice and V4L2Subdevide with\nthe fromEntityName() helper where possible. The returned pointer is\nmanaged as a std::unique_ptr<>, which simplifies the VimcCameraData\ndestructor.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/vimc/vimc.cpp | 24 +++++++++---------------\n 1 file changed, 9 insertions(+), 15 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 2a5054a8b1b8..72256f5b4190 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -42,19 +42,13 @@ class VimcCameraData : public CameraData\n {\n public:\n \tVimcCameraData(PipelineHandler *pipe, MediaDevice *media)\n-\t\t: CameraData(pipe), media_(media), sensor_(nullptr),\n-\t\t  debayer_(nullptr), scaler_(nullptr), video_(nullptr),\n-\t\t  raw_(nullptr)\n+\t\t: CameraData(pipe), media_(media), sensor_(nullptr)\n \t{\n \t}\n \n \t~VimcCameraData()\n \t{\n \t\tdelete sensor_;\n-\t\tdelete debayer_;\n-\t\tdelete scaler_;\n-\t\tdelete video_;\n-\t\tdelete raw_;\n \t}\n \n \tint init();\n@@ -62,10 +56,10 @@ public:\n \n \tMediaDevice *media_;\n \tCameraSensor *sensor_;\n-\tV4L2Subdevice *debayer_;\n-\tV4L2Subdevice *scaler_;\n-\tV4L2VideoDevice *video_;\n-\tV4L2VideoDevice *raw_;\n+\tstd::unique_ptr<V4L2Subdevice> debayer_;\n+\tstd::unique_ptr<V4L2Subdevice> scaler_;\n+\tstd::unique_ptr<V4L2VideoDevice> video_;\n+\tstd::unique_ptr<V4L2VideoDevice> raw_;\n \tStream stream_;\n };\n \n@@ -472,21 +466,21 @@ int VimcCameraData::init()\n \tif (ret)\n \t\treturn ret;\n \n-\tdebayer_ = new V4L2Subdevice(media_->getEntityByName(\"Debayer B\"));\n+\tdebayer_ = V4L2Subdevice::fromEntityName(media_, \"Debayer B\");\n \tif (debayer_->open())\n \t\treturn -ENODEV;\n \n-\tscaler_ = new V4L2Subdevice(media_->getEntityByName(\"Scaler\"));\n+\tscaler_ = V4L2Subdevice::fromEntityName(media_, \"Scaler\");\n \tif (scaler_->open())\n \t\treturn -ENODEV;\n \n-\tvideo_ = new V4L2VideoDevice(media_->getEntityByName(\"RGB/YUV Capture\"));\n+\tvideo_ = V4L2VideoDevice::fromEntityName(media_, \"RGB/YUV Capture\");\n \tif (video_->open())\n \t\treturn -ENODEV;\n \n \tvideo_->bufferReady.connect(this, &VimcCameraData::bufferReady);\n \n-\traw_ = new V4L2VideoDevice(media_->getEntityByName(\"Raw Capture 1\"));\n+\traw_ = V4L2VideoDevice::fromEntityName(media_, \"Raw Capture 1\");\n \tif (raw_->open())\n \t\treturn -ENODEV;\n \n","prefixes":["libcamera-devel","2/3"]}