[libcamera-devel] [PATCH 01/20] libcamera: pipeline: simple: Manage converter with std::unique_ptr<>
paul.elder at ideasonboard.com
paul.elder at ideasonboard.com
Wed Feb 17 10:52:16 CET 2021
Hi Laurent,
On Mon, Feb 01, 2021 at 12:46:43AM +0200, Laurent Pinchart wrote:
> 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 at ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
> ---
> src/libcamera/pipeline/simple/simple.cpp | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index 23320d2687e1..b7aa3d034568 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);
> }
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
More information about the libcamera-devel
mailing list