diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-14 01:35:22 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-14 19:06:40 +0200 |
commit | acf18e4265dec2991e62f7c8baecfacf1a6708b3 (patch) | |
tree | 9113e55c2012de225f694d2824fdda444e8e8f56 | |
parent | 9a61a134669c2240100fd1ccadaf974f86fe4655 (diff) |
libcamera: Switch from utils::make_unique to std::make_unique
Now that we're using C++-14, drop utils::make_unique for
std::make_unique.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r-- | src/android/camera_device.cpp | 2 | ||||
-rw-r--r-- | src/ipa/ipa_vimc.cpp | 3 | ||||
-rw-r--r-- | src/ipa/libipa/ipa_interface_wrapper.cpp | 2 | ||||
-rw-r--r-- | src/ipa/rkisp1/rkisp1.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/bound_method.cpp | 5 | ||||
-rw-r--r-- | src/libcamera/control_serializer.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/device_enumerator.cpp | 5 | ||||
-rw-r--r-- | src/libcamera/include/ipa_proxy.h | 3 | ||||
-rw-r--r-- | src/libcamera/include/utils.h | 7 | ||||
-rw-r--r-- | src/libcamera/ipa_manager.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/pipeline/rkisp1/rkisp1.cpp | 14 | ||||
-rw-r--r-- | src/libcamera/pipeline/uvcvideo.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/pipeline/vimc.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp | 3 | ||||
-rw-r--r-- | src/libcamera/utils.cpp | 5 | ||||
-rw-r--r-- | src/libcamera/v4l2_device.cpp | 2 | ||||
-rw-r--r-- | src/libcamera/v4l2_videodevice.cpp | 2 | ||||
-rw-r--r-- | src/v4l2/v4l2_camera.cpp | 3 | ||||
-rw-r--r-- | src/v4l2/v4l2_camera_proxy.cpp | 2 | ||||
-rw-r--r-- | test/ipa/ipa_wrappers_test.cpp | 3 | ||||
-rw-r--r-- | 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 a98fd744..67c1d47e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -860,7 +860,7 @@ std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number * Currently: 12 entries, 36 bytes */ std::unique_ptr<CameraMetadata> resultMetadata = - utils::make_unique<CameraMetadata>(15, 50); + std::make_unique<CameraMetadata>(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<IPAVimc>()); + return new IPAInterfaceWrapper(std::make_unique<IPAVimc>()); } } 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<MyIPA>()); + * return new IPAInterfaceWrapper(std::make_unique<MyIPA>()); * } * \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<IPARkISP1>()); + return new IPAInterfaceWrapper(std::make_unique<IPARkISP1>()); } } 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<BoundMethodPackBase> pack, case ConnectionTypeQueued: { std::unique_ptr<Message> msg = - utils::make_unique<InvokeMessage>(this, pack, nullptr, deleteMethod); + std::make_unique<InvokeMessage>(this, pack, nullptr, deleteMethod); object_->postMessage(std::move(msg)); return false; } @@ -93,7 +92,7 @@ bool BoundMethodBase::activatePack(std::shared_ptr<BoundMethodPackBase> pack, Semaphore semaphore; std::unique_ptr<Message> msg = - utils::make_unique<InvokeMessage>(this, pack, &semaphore, deleteMethod); + std::make_unique<InvokeMessage>(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<ControlInfoMap>(ByteStreamBuffer & * \todo Find a way to preserve the control name for debugging * purpose. */ - controlIds_.emplace_back(utils::make_unique<ControlId>(entry.id, "", type)); + controlIds_.emplace_back(std::make_unique<ControlId>(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> DeviceEnumerator::create() std::unique_ptr<DeviceEnumerator> enumerator; #ifdef HAVE_LIBUDEV - enumerator = utils::make_unique<DeviceEnumeratorUdev>(); + enumerator = std::make_unique<DeviceEnumeratorUdev>(); if (!enumerator->init()) return enumerator; #endif @@ -154,7 +153,7 @@ std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create() * Either udev is not available or udev initialization failed. Fall back * on the sysfs enumerator. */ - enumerator = utils::make_unique<DeviceEnumeratorSysfs>(); + enumerator = std::make_unique<DeviceEnumeratorSysfs>(); 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 <ipa/ipa_interface.h> #include "ipa_module.h" -#include "utils.h" namespace libcamera { @@ -56,7 +55,7 @@ public: \ proxy##Factory() : IPAProxyFactory(#proxy) {} \ std::unique_ptr<IPAProxy> create(IPAModule *ipam) \ { \ - return utils::make_unique<proxy>(ipam); \ + return std::make_unique<proxy>(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<typename T, typename... Args> -std::unique_ptr<T> make_unique(Args&&... args) -{ - return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); -} - char *secure_getenv(const char *name); template<class InputIt1, class InputIt2> 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<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe, if (!ctx) return nullptr; - return utils::make_unique<IPAContextWrapper>(ctx); + return std::make_unique<IPAContextWrapper>(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<IPU3CameraData> data = - utils::make_unique<IPU3CameraData>(this); + std::make_unique<IPU3CameraData>(this); std::set<Stream *> 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<RkISP1ActionSetSensor>(frame, - sensor_, - controls)); + timeline_.scheduleAction(std::make_unique<RkISP1ActionSetSensor>(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<RkISP1ActionQueueBuffers>(data->frame_, - data, - this)); + data->timeline_.scheduleAction(std::make_unique<RkISP1ActionQueueBuffers>(data->frame_, + data, + this)); data->frame_++; @@ -892,7 +892,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) int ret; std::unique_ptr<RkISP1CameraData> data = - utils::make_unique<RkISP1CameraData>(this); + std::make_unique<RkISP1CameraData>(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<UVCCameraData> data = utils::make_unique<UVCCameraData>(this); + std::unique_ptr<UVCCameraData> data = std::make_unique<UVCCameraData>(this); /* Locate and initialise the camera data with the default video node. */ const std::vector<MediaEntity *> &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<VimcCameraData> data = utils::make_unique<VimcCameraData>(this); + std::unique_ptr<VimcCameraData> data = std::make_unique<VimcCameraData>(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<IPAModule> ipam = utils::make_unique<IPAModule>(argv[1]); + std::unique_ptr<IPAModule> ipam = std::make_unique<IPAModule>(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 @@ -71,11 +71,6 @@ char *secure_getenv(const char *name) } /** - * \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) * \brief Count the number of elements in the intersection of two ranges 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<V4L2ControlId>(ctrl)); + controlIds_.emplace_back(std::make_unique<V4L2ControlId>(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<FrameBuffer>(std::move(planes)); + return std::make_unique<FrameBuffer>(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 <errno.h> #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<Buffer> metadata = - utils::make_unique<Buffer>(request->cookie(), buffer->metadata()); + std::make_unique<Buffer>(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> camera) : refcount_(0), index_(index), bufferCount_(0), currentBuf_(0), - vcam_(utils::make_unique<V4L2Camera>(camera)) + vcam_(std::make_unique<V4L2Camera>(camera)) { querycap(camera); } diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index e711e4fe..1ae17811 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<IPAInterface> intf = utils::make_unique<TestIPAInterface>(); + std::unique_ptr<IPAInterface> intf = std::make_unique<TestIPAInterface>(); 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 7ebedb55..478bc79d 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>(Message::None)); + receiver.postMessage(std::make_unique<Message>(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>(Message::None)); + slowReceiver->postMessage(std::make_unique<Message>(Message::None)); this_thread::sleep_for(chrono::milliseconds(10)); |