diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-12-09 13:13:38 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-12-14 15:46:04 +0200 |
commit | 3129fcae43ce139cb1e158cb5255428afb8952ec (patch) | |
tree | 84e902862aa325a95a40f7241b63e11add6bee0c /src/libcamera/pipeline/uvcvideo | |
parent | 1c2b54a0173f5ad6d792617246439ec1823bab5a (diff) |
libcamera: pipeline: Manage resources with std::unique_ptr<>
Replace manual resource destruction with std::unique_ptr<> where
applicable. This removes the need for several destructors.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/uvcvideo')
-rw-r--r-- | src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 87b0f03d..e54f45bb 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -9,6 +9,7 @@ #include <fstream> #include <iomanip> #include <math.h> +#include <memory> #include <tuple> #include <libcamera/camera.h> @@ -35,21 +36,16 @@ class UVCCameraData : public CameraData { public: UVCCameraData(PipelineHandler *pipe) - : CameraData(pipe), video_(nullptr) + : CameraData(pipe) { } - ~UVCCameraData() - { - delete video_; - } - int init(MediaDevice *media); void addControl(uint32_t cid, const ControlInfo &v4l2info, ControlInfoMap::Map *ctrls); void bufferReady(FrameBuffer *buffer); - V4L2VideoDevice *video_; + std::unique_ptr<V4L2VideoDevice> video_; Stream stream_; }; @@ -499,7 +495,7 @@ int UVCCameraData::init(MediaDevice *media) } /* Create and open the video device. */ - video_ = new V4L2VideoDevice(*entity); + video_ = std::make_unique<V4L2VideoDevice>(*entity); ret = video_->open(); if (ret) return ret; |