summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-02 16:17:31 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-03 04:32:30 +0300
commit3697c93a8d720a01167bb6f6ec3846de561d2e7a (patch)
tree13f484f5bd9402d004a263f339e7feb2334197ec
parentdb7f214547143a6c8496f4e725a35c9bf0b07133 (diff)
libcamera: camera_sensor: Store subdevice in std::unique_ptr
Avoid the need for a manual delete in the destructor by using a unique pointer. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/libcamera/camera_sensor.cpp5
-rw-r--r--src/libcamera/include/camera_sensor.h3
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 4585d6d3..d6a823f4 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -133,7 +133,6 @@ LOG_DEFINE_CATEGORY(CameraSensor);
CameraSensor::CameraSensor(const MediaEntity *entity)
: entity_(entity), properties_(properties::properties)
{
- subdev_ = new V4L2Subdevice(entity);
}
/**
@@ -141,7 +140,6 @@ CameraSensor::CameraSensor(const MediaEntity *entity)
*/
CameraSensor::~CameraSensor()
{
- delete subdev_;
}
/**
@@ -197,7 +195,8 @@ int CameraSensor::init()
else
model_ = entityName;
- /* Open the subdev. */
+ /* Create and open the subdev. */
+ subdev_ = std::make_unique<V4L2Subdevice>(entity_);
ret = subdev_->open();
if (ret < 0)
return ret;
diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h
index f39ea96d..92cd9035 100644
--- a/src/libcamera/include/camera_sensor.h
+++ b/src/libcamera/include/camera_sensor.h
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_CAMERA_SENSOR_H__
#define __LIBCAMERA_CAMERA_SENSOR_H__
+#include <memory>
#include <string>
#include <vector>
@@ -68,7 +69,7 @@ protected:
private:
const MediaEntity *entity_;
- V4L2Subdevice *subdev_;
+ std::unique_ptr<V4L2Subdevice> subdev_;
std::string model_;
std::vector<unsigned int> mbusCodes_;