From acf18e4265dec2991e62f7c8baecfacf1a6708b3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 14 Jan 2020 01:35:22 +0200 Subject: libcamera: Switch from utils::make_unique to std::make_unique MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 +- src/libcamera/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 +- 20 files changed, 26 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a98fd744..67c1d47e 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 8f03e811..4751ad91 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 3628a785..b93c1c1f 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 a8dd1645..438b3c66 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 8e95c7ee..e18c2eb4 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 a5d6d875..803ac16c 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 0b596bce..a8b5c90f 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 add40b4b..e696551a 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 badc7753..e467eb21 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 90eef12d..92adc6c4 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 7894084a..8e8e3709 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 389a99cf..0b3dd975 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 47916ffb..83093676 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 1700ac96..c99560a4 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 07380c16..7d6287c7 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 5de9e481..4beffdab 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 c13eddc8..1698d245 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 66adf7b2..18220b81 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 44cb4e7c..e7018b56 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 28e58722..3013a3d1 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); } -- cgit v1.2.1