{"id":3365,"url":"https://patchwork.libcamera.org/api/1.1/patches/3365/?format=json","web_url":"https://patchwork.libcamera.org/patch/3365/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200401091553.28187-2-kieran.bingham@ideasonboard.com>","date":"2020-04-01T09:15:51","name":"[libcamera-devel,v4.1,1/3] libcamera: Define {unique, shared}_ptr helpers","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"26820e886f8648c6e3e8995627cb15f7b9226af4","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3365/mbox/","series":[{"id":791,"url":"https://patchwork.libcamera.org/api/1.1/series/791/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=791","date":"2020-04-01T09:15:50","name":"Miscellaneous Code Improvements for mаster","version":1,"mbox":"https://patchwork.libcamera.org/series/791/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3365/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3365/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1C7EA629B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Apr 2020 11:16:01 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8DC23A35;\n\tWed,  1 Apr 2020 11:16:00 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wYZzEi/+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1585732560;\n\tbh=JWb2qxK20Bve81hLYR1HoTxArfxYedUjC7sXo2lZhFo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=wYZzEi/+WWeiesHD1VAUdA9Ei96HOF+bXGzDaGR6OitM1CMtiwccq6m+9V72AuEgD\n\tx6j8dAkEioisjHOj+iDOVP6VO0wD9taTqHu5UVaWGgXZwFbM61N4XR/igD6oR4RG4L\n\ttGhPwCUX46M1y+MM2pcJCrk3a09NNeuwGRslznLQ=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Wed,  1 Apr 2020 10:15:51 +0100","Message-Id":"<20200401091553.28187-2-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200401091553.28187-1-kieran.bingham@ideasonboard.com>","References":"<20200401091553.28187-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4.1 1/3] libcamera: Define {unique,\n\tshared}_ptr helpers","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>","X-List-Received-Date":"Wed, 01 Apr 2020 09:16:01 -0000"},"content":"The politics in libcamera has become fuzzy and hazed. It's no longer\nclear as to which side of the fence any of our code belongs.\n\nClarify the opinions of the codebase to make the intentions clear to the\ncompiler.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/meson.build            |  1 +\n include/libcamera/pointers.h             | 18 ++++++++++++++++++\n src/libcamera/include/v4l2_videodevice.h | 11 ++++++-----\n src/libcamera/v4l2_videodevice.cpp       | 14 +++++++-------\n 4 files changed, 32 insertions(+), 12 deletions(-)\n create mode 100644 include/libcamera/pointers.h","diff":"diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 23c01d3837ba..ba48e44492f8 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -12,6 +12,7 @@ libcamera_api = files([\n     'logging.h',\n     'object.h',\n     'pixelformats.h',\n+    'pointers.h',\n     'request.h',\n     'signal.h',\n     'span.h',\ndiff --git a/include/libcamera/pointers.h b/include/libcamera/pointers.h\nnew file mode 100644\nindex 000000000000..637c0c30ff83\n--- /dev/null\n+++ b/include/libcamera/pointers.h\n@@ -0,0 +1,18 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Kieran Bingham\n+ *\n+ * pointers.h - pointer declarations\n+ */\n+\n+#ifndef __LIBCAMERA_POINTERS_H__\n+#define __LIBCAMERA_POINTERS_H__\n+\n+namespace libcamera {\n+\n+#define capitalist_ptr unique_ptr\n+#define socialist_ptr shared_ptr\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_POINTERS_H__ */\ndiff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 7d7c4a9e6ebd..d059b2841717 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -18,6 +18,7 @@\n #include <libcamera/buffer.h>\n #include <libcamera/geometry.h>\n #include <libcamera/pixelformats.h>\n+#include <libcamera/pointers.h>\n #include <libcamera/signal.h>\n \n #include \"formats.h\"\n@@ -111,7 +112,7 @@ class V4L2BufferCache\n {\n public:\n \tV4L2BufferCache(unsigned int numEntries);\n-\tV4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>> &buffers);\n+\tV4L2BufferCache(const std::vector<std::capitalist_ptr<FrameBuffer>> &buffers);\n \t~V4L2BufferCache();\n \n \tint get(const FrameBuffer &buffer);\n@@ -213,9 +214,9 @@ public:\n \tint setCompose(Rectangle *rect);\n \n \tint allocateBuffers(unsigned int count,\n-\t\t\t    std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\t\t\t    std::vector<std::capitalist_ptr<FrameBuffer>> *buffers);\n \tint exportBuffers(unsigned int count,\n-\t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\t\t\t  std::vector<std::capitalist_ptr<FrameBuffer>> *buffers);\n \tint importBuffers(unsigned int count);\n \tint releaseBuffers();\n \n@@ -253,8 +254,8 @@ private:\n \n \tint requestBuffers(unsigned int count, enum v4l2_memory memoryType);\n \tint createBuffers(unsigned int count,\n-\t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n-\tstd::unique_ptr<FrameBuffer> createBuffer(unsigned int index);\n+\t\t\t  std::vector<std::capitalist_ptr<FrameBuffer>> *buffers);\n+\tstd::capitalist_ptr<FrameBuffer> createBuffer(unsigned int index);\n \tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\n \n \tvoid bufferAvailable(EventNotifier *notifier);\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex eb33a68e50d6..d7b08a787fdc 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -176,10 +176,10 @@ V4L2BufferCache::V4L2BufferCache(unsigned int numEntries)\n  * implement buffer export, with all buffers added to the cache when they are\n  * allocated.\n  */\n-V4L2BufferCache::V4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>> &buffers)\n+V4L2BufferCache::V4L2BufferCache(const std::vector<std::capitalist_ptr<FrameBuffer>> &buffers)\n \t: lastUsedCounter_(1), missCounter_(0)\n {\n-\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers)\n+\tfor (const std::capitalist_ptr<FrameBuffer> &buffer : buffers)\n \t\tcache_.emplace_back(true,\n \t\t\t\t    lastUsedCounter_.fetch_add(1, std::memory_order_acq_rel),\n \t\t\t\t    buffer->planes());\n@@ -1187,7 +1187,7 @@ int V4L2VideoDevice::requestBuffers(unsigned int count,\n  * \\retval -EBUSY buffers have already been allocated or imported\n  */\n int V4L2VideoDevice::allocateBuffers(unsigned int count,\n-\t\t\t\t     std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+\t\t\t\t     std::vector<std::capitalist_ptr<FrameBuffer>> *buffers)\n {\n \tint ret = createBuffers(count, buffers);\n \tif (ret < 0)\n@@ -1231,7 +1231,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,\n  * \\retval -EBUSY buffers have already been allocated or imported\n  */\n int V4L2VideoDevice::exportBuffers(unsigned int count,\n-\t\t\t\t   std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+\t\t\t\t   std::vector<std::capitalist_ptr<FrameBuffer>> *buffers)\n {\n \tint ret = createBuffers(count, buffers);\n \tif (ret < 0)\n@@ -1243,7 +1243,7 @@ int V4L2VideoDevice::exportBuffers(unsigned int count,\n }\n \n int V4L2VideoDevice::createBuffers(unsigned int count,\n-\t\t\t\t   std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+\t\t\t\t   std::vector<std::capitalist_ptr<FrameBuffer>> *buffers)\n {\n \tif (cache_) {\n \t\tLOG(V4L2, Error) << \"Buffers already allocated\";\n@@ -1255,7 +1255,7 @@ int V4L2VideoDevice::createBuffers(unsigned int count,\n \t\treturn ret;\n \n \tfor (unsigned i = 0; i < count; ++i) {\n-\t\tstd::unique_ptr<FrameBuffer> buffer = createBuffer(i);\n+\t\tstd::capitalist_ptr<FrameBuffer> buffer = createBuffer(i);\n \t\tif (!buffer) {\n \t\t\tLOG(V4L2, Error) << \"Unable to create buffer\";\n \n@@ -1271,7 +1271,7 @@ int V4L2VideoDevice::createBuffers(unsigned int count,\n \treturn count;\n }\n \n-std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n+std::capitalist_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n {\n \tstruct v4l2_plane v4l2Planes[VIDEO_MAX_PLANES] = {};\n \tstruct v4l2_buffer buf = {};\n","prefixes":["libcamera-devel","v4.1","1/3"]}