diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-12-24 18:01:43 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-03 00:58:58 +0200 |
commit | 96bcf66ac7c079f5a5a6edfe075aed7529a683c9 (patch) | |
tree | 7d7373c12228624870e69ba246eb0024399afaa7 /src | |
parent | 817a4b4472039251944cba131b25f75cc067f9b1 (diff) |
libcamera: pipeline: simple: Manage converter with std::unique_ptr<>
Replace manual destruction of the converter with std::unique_ptr<>. This
removes the need for the SimplePipelineHandler destructor.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/simple/simple.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35cd34dd..ea1a2314 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -116,7 +116,6 @@ class SimplePipelineHandler : public PipelineHandler { public: SimplePipelineHandler(CameraManager *manager); - ~SimplePipelineHandler(); CameraConfiguration *generateConfiguration(Camera *camera, const StreamRoles &roles) override; @@ -132,7 +131,7 @@ public: V4L2VideoDevice *video(const MediaEntity *entity); V4L2Subdevice *subdev(const MediaEntity *entity); - SimpleConverter *converter() { return converter_; } + SimpleConverter *converter() { return converter_.get(); } protected: int queueRequestDevice(Camera *camera, Request *request) override; @@ -151,7 +150,7 @@ private: std::map<const MediaEntity *, std::unique_ptr<V4L2VideoDevice>> videos_; std::map<const MediaEntity *, V4L2Subdevice> subdevs_; - SimpleConverter *converter_; + std::unique_ptr<SimpleConverter> converter_; bool useConverter_; std::vector<std::unique_ptr<FrameBuffer>> converterBuffers_; std::queue<FrameBuffer *> converterQueue_; @@ -507,15 +506,10 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() */ SimplePipelineHandler::SimplePipelineHandler(CameraManager *manager) - : PipelineHandler(manager), converter_(nullptr) + : PipelineHandler(manager) { } -SimplePipelineHandler::~SimplePipelineHandler() -{ - delete converter_; -} - CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera, const StreamRoles &roles) { @@ -763,12 +757,11 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) /* Open the converter, if any. */ if (converter) { - converter_ = new SimpleConverter(converter); + converter_ = std::make_unique<SimpleConverter>(converter); if (converter_->open() < 0) { LOG(SimplePipeline, Warning) << "Failed to open converter, disabling format conversion"; - delete converter_; - converter_ = nullptr; + converter_.reset(); } else { converter_->bufferReady.connect(this, &SimplePipelineHandler::converterDone); } |