From patchwork Tue Jan 14 00:15:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2641 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3846060709 for ; Tue, 14 Jan 2020 01:15:48 +0100 (CET) Received: from pendragon.ideasonboard.com (cpc108967-cmbg20-2-0-cust420.5-4.cable.virginm.net [81.101.7.165]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C02759D7 for ; Tue, 14 Jan 2020 01:15:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1578960947; bh=7mpupHpBUFXYQcXCQakYCBiVXcuj+UNKvp8MQK3Www0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GpOY5bCkcHrj/xZnfsY4GWbGkCRPE+hKCz1OjTrWFVVSYwy3sYezxia/Gqnl6qgQz 38MP3Xir7w4jiTavb+chzJBRTHK/BEMJl+lzEcRQBRcXYyuEIkdsfEouZjC1gC+x// hlZrQqQlCi+vqfpwYQ5d3qaK2Qqc/moqpc2TlOIE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Jan 2020 02:15:31 +0200 Message-Id: <20200114001531.27129-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114001531.27129-1-laurent.pinchart@ideasonboard.com> References: <20200114001531.27129-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: Switch from utils::make_unique to std::make_unique X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2020 00:15:48 -0000 Now that we're using C++-14, drop utils::make_unique for std::make_unique. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/android/camera_device.cpp | 2 +- src/ipa/ipa_vimc.cpp | 3 +-- src/ipa/libipa/ipa_interface_wrapper.cpp | 2 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/libcamera/bound_method.cpp | 5 ++--- src/libcamera/control_serializer.cpp | 2 +- src/libcamera/device_enumerator.cpp | 5 ++--- src/libcamera/include/ipa_proxy.h | 3 +-- src/libcamera/include/utils.h | 7 ------- src/libcamera/ipa_manager.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 14 +++++++------- src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- .../proxy/worker/ipa_proxy_linux_worker.cpp | 3 +-- src/libcamera/utils.cpp | 5 ----- src/libcamera/v4l2_device.cpp | 2 +- src/libcamera/v4l2_videodevice.cpp | 2 +- src/v4l2/v4l2_camera.cpp | 3 +-- src/v4l2/v4l2_camera_proxy.cpp | 2 +- test/ipa/ipa_wrappers_test.cpp | 3 +-- test/message.cpp | 5 ++--- 22 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a98fd744f534..67c1d47e67ed 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -860,7 +860,7 @@ std::unique_ptr CameraDevice::getResultMetadata(int frame_number * Currently: 12 entries, 36 bytes */ std::unique_ptr resultMetadata = - utils::make_unique(15, 50); + std::make_unique(15, 50); if (!resultMetadata->isValid()) { LOG(HAL, Error) << "Failed to allocate static metadata"; return nullptr; diff --git a/src/ipa/ipa_vimc.cpp b/src/ipa/ipa_vimc.cpp index 8f03e811acc7..4751ad919a0f 100644 --- a/src/ipa/ipa_vimc.cpp +++ b/src/ipa/ipa_vimc.cpp @@ -20,7 +20,6 @@ #include "libipa/ipa_interface_wrapper.h" #include "log.h" -#include "utils.h" namespace libcamera { @@ -113,7 +112,7 @@ const struct IPAModuleInfo ipaModuleInfo = { struct ipa_context *ipaCreate() { - return new IPAInterfaceWrapper(utils::make_unique()); + return new IPAInterfaceWrapper(std::make_unique()); } } diff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp index 3628a785dc3e..b93c1c1f1c1a 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.cpp +++ b/src/ipa/libipa/ipa_interface_wrapper.cpp @@ -45,7 +45,7 @@ namespace libcamera { * * struct ipa_context *ipaCreate() * { - * return new IPAInterfaceWrapper(utils::make_unique()); + * return new IPAInterfaceWrapper(std::make_unique()); * } * \endcode * diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index a8dd1645d3e8..438b3c66f77a 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -278,7 +278,7 @@ const struct IPAModuleInfo ipaModuleInfo = { struct ipa_context *ipaCreate() { - return new IPAInterfaceWrapper(utils::make_unique()); + return new IPAInterfaceWrapper(std::make_unique()); } } diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp index 8e95c7eec92c..e18c2eb4c68e 100644 --- a/src/libcamera/bound_method.cpp +++ b/src/libcamera/bound_method.cpp @@ -10,7 +10,6 @@ #include "message.h" #include "semaphore.h" #include "thread.h" -#include "utils.h" /** * \file bound_method.h @@ -84,7 +83,7 @@ bool BoundMethodBase::activatePack(std::shared_ptr pack, case ConnectionTypeQueued: { std::unique_ptr msg = - utils::make_unique(this, pack, nullptr, deleteMethod); + std::make_unique(this, pack, nullptr, deleteMethod); object_->postMessage(std::move(msg)); return false; } @@ -93,7 +92,7 @@ bool BoundMethodBase::activatePack(std::shared_ptr pack, Semaphore semaphore; std::unique_ptr msg = - utils::make_unique(this, pack, &semaphore, deleteMethod); + std::make_unique(this, pack, &semaphore, deleteMethod); object_->postMessage(std::move(msg)); semaphore.acquire(); diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index a5d6d875c76f..803ac16c2456 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -414,7 +414,7 @@ ControlInfoMap ControlSerializer::deserialize(ByteStreamBuffer & * \todo Find a way to preserve the control name for debugging * purpose. */ - controlIds_.emplace_back(utils::make_unique(entry.id, "", type)); + controlIds_.emplace_back(std::make_unique(entry.id, "", type)); if (entry.offset != values.offset()) { LOG(Serializer, Error) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 0b596bcec363..a8b5c90f5a5d 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -13,7 +13,6 @@ #include "log.h" #include "media_device.h" -#include "utils.h" /** * \file device_enumerator.h @@ -145,7 +144,7 @@ std::unique_ptr DeviceEnumerator::create() std::unique_ptr enumerator; #ifdef HAVE_LIBUDEV - enumerator = utils::make_unique(); + enumerator = std::make_unique(); if (!enumerator->init()) return enumerator; #endif @@ -154,7 +153,7 @@ std::unique_ptr DeviceEnumerator::create() * Either udev is not available or udev initialization failed. Fall back * on the sysfs enumerator. */ - enumerator = utils::make_unique(); + enumerator = std::make_unique(); if (!enumerator->init()) return enumerator; diff --git a/src/libcamera/include/ipa_proxy.h b/src/libcamera/include/ipa_proxy.h index add40b4b3368..e696551af39f 100644 --- a/src/libcamera/include/ipa_proxy.h +++ b/src/libcamera/include/ipa_proxy.h @@ -14,7 +14,6 @@ #include #include "ipa_module.h" -#include "utils.h" namespace libcamera { @@ -56,7 +55,7 @@ public: \ proxy##Factory() : IPAProxyFactory(#proxy) {} \ std::unique_ptr create(IPAModule *ipam) \ { \ - return utils::make_unique(ipam); \ + return std::make_unique(ipam); \ } \ }; \ static proxy##Factory global_##proxy##Factory; diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index badc77533fa1..e467eb21c518 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -32,13 +32,6 @@ namespace utils { const char *basename(const char *path); -/* C++11 doesn't provide std::make_unique */ -template -std::unique_ptr make_unique(Args&&... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - char *secure_getenv(const char *name); template diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 90eef12dbaf5..92adc6c45015 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -264,7 +264,7 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, if (!ctx) return nullptr; - return utils::make_unique(ctx); + return std::make_unique(ctx); } } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 7894084a025e..8e8e370922ad 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -876,7 +876,7 @@ int PipelineHandlerIPU3::registerCameras() unsigned int numCameras = 0; for (unsigned int id = 0; id < 4 && numCameras < 2; ++id) { std::unique_ptr data = - utils::make_unique(this); + std::make_unique(this); std::set streams = { &data->outStream_, &data->vfStream_, diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 389a99cf52bd..0b3dd9759387 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -388,9 +388,9 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, switch (action.operation) { case RKISP1_IPA_ACTION_V4L2_SET: { const ControlList &controls = action.controls[0]; - timeline_.scheduleAction(utils::make_unique(frame, - sensor_, - controls)); + timeline_.scheduleAction(std::make_unique(frame, + sensor_, + controls)); break; } case RKISP1_IPA_ACTION_PARAM_FILLED: { @@ -846,9 +846,9 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, op.controls = { request->controls() }; data->ipa_->processEvent(op); - data->timeline_.scheduleAction(utils::make_unique(data->frame_, - data, - this)); + data->timeline_.scheduleAction(std::make_unique(data->frame_, + data, + this)); data->frame_++; @@ -892,7 +892,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) int ret; std::unique_ptr data = - utils::make_unique(this); + std::make_unique(this); ControlInfoMap::Map ctrls; ctrls.emplace(std::piecewise_construct, diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 47916ffb4536..83093676ec73 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -296,7 +296,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) if (!media) return false; - std::unique_ptr data = utils::make_unique(this); + std::unique_ptr data = std::make_unique(this); /* Locate and initialise the camera data with the default video node. */ const std::vector &entities = media->entities(); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 1700ac967299..c99560a45cfa 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -365,7 +365,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) if (!media) return false; - std::unique_ptr data = utils::make_unique(this); + std::unique_ptr data = std::make_unique(this); data->ipa_ = IPAManager::instance()->createIPA(this, 0, 0); if (data->ipa_ == nullptr) diff --git a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp b/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp index 07380c16e2d5..7d6287c7115b 100644 --- a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp +++ b/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp @@ -17,7 +17,6 @@ #include "ipc_unixsocket.h" #include "log.h" #include "thread.h" -#include "utils.h" using namespace libcamera; @@ -58,7 +57,7 @@ int main(int argc, char **argv) << "Starting worker for IPA module " << argv[1] << " with IPC fd = " << fd; - std::unique_ptr ipam = utils::make_unique(argv[1]); + std::unique_ptr ipam = std::make_unique(argv[1]); if (!ipam->isValid() || !ipam->load()) { LOG(IPAProxyLinuxWorker, Error) << "IPAModule " << argv[1] << " should be valid but isn't"; diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 5de9e4813353..4beffdab5eb6 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -70,11 +70,6 @@ char *secure_getenv(const char *name) #endif } -/** - * \fn libcamera::utils::make_unique(Args &&... args) - * \brief Constructs an object of type T and wraps it in a std::unique_ptr. - */ - /** * \fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1, * InputIt2 first2, InputIt2 last2) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index c13eddc84c7c..1698d2451449 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -380,7 +380,7 @@ void V4L2Device::listControls() continue; } - controlIds_.emplace_back(utils::make_unique(ctrl)); + controlIds_.emplace_back(std::make_unique(ctrl)); ctrls.emplace(controlIds_.back().get(), V4L2ControlRange(ctrl)); } diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 66adf7b29572..18220b81af21 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1054,7 +1054,7 @@ V4L2VideoDevice::createBuffer(const struct v4l2_buffer &buf) planes.push_back(std::move(plane)); } - return utils::make_unique(std::move(planes)); + return std::make_unique(std::move(planes)); } FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index, diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 44cb4e7c551b..e7018b566475 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -10,7 +10,6 @@ #include #include "log.h" -#include "utils.h" using namespace libcamera; @@ -81,7 +80,7 @@ void V4L2Camera::requestComplete(Request *request) bufferLock_.lock(); FrameBuffer *buffer = request->buffers().begin()->second; std::unique_ptr metadata = - utils::make_unique(request->cookie(), buffer->metadata()); + std::make_unique(request->cookie(), buffer->metadata()); completedBuffers_.push_back(std::move(metadata)); bufferLock_.unlock(); diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 28e587226a97..3013a3d17568 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -32,7 +32,7 @@ LOG_DECLARE_CATEGORY(V4L2Compat); V4L2CameraProxy::V4L2CameraProxy(unsigned int index, std::shared_ptr camera) : refcount_(0), index_(index), bufferCount_(0), currentBuf_(0), - vcam_(utils::make_unique(camera)) + vcam_(std::make_unique(camera)) { querycap(camera); } diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index e711e4fe318d..1ae1781169c8 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -18,7 +18,6 @@ #include "device_enumerator.h" #include "ipa_context_wrapper.h" #include "media_device.h" -#include "utils.h" #include "v4l2_subdevice.h" #include "test.h" @@ -254,7 +253,7 @@ protected: if (ret) return TestFail; - std::unique_ptr intf = utils::make_unique(); + std::unique_ptr intf = std::make_unique(); wrapper_ = new IPAContextWrapper(new IPAInterfaceWrapper(std::move(intf))); wrapper_->queueFrameAction.connect(this, &IPAWrappersTest::queueFrameAction); diff --git a/test/message.cpp b/test/message.cpp index 7ebedb557502..478bc79dffa6 100644 --- a/test/message.cpp +++ b/test/message.cpp @@ -12,7 +12,6 @@ #include "message.h" #include "thread.h" #include "test.h" -#include "utils.h" using namespace std; using namespace libcamera; @@ -92,7 +91,7 @@ protected: thread_.start(); - receiver.postMessage(utils::make_unique(Message::None)); + receiver.postMessage(std::make_unique(Message::None)); this_thread::sleep_for(chrono::milliseconds(100)); @@ -114,7 +113,7 @@ protected: */ SlowMessageReceiver *slowReceiver = new SlowMessageReceiver(); slowReceiver->moveToThread(&thread_); - slowReceiver->postMessage(utils::make_unique(Message::None)); + slowReceiver->postMessage(std::make_unique(Message::None)); this_thread::sleep_for(chrono::milliseconds(10));