summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-17 00:37:40 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-18 18:13:15 +0300
commitd97cafdf3c60afb75fa38d8b2f17b816c934ad9d (patch)
tree6b38e0f7384c6eef31eebc60f7f6ac732a994fa6
parent889b70d62d1b2fa974951866cb8bbebe66fce3a7 (diff)
libcamera: v4l2_subdevice: Close subdevice when destroyed
Make sure the subdevice file descriptor isn't leaked by closing it when the V4L2Subdevice instance is destroyed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--src/libcamera/include/v4l2_subdevice.h1
-rw-r--r--src/libcamera/v4l2_subdevice.cpp5
2 files changed, 6 insertions, 0 deletions
diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h
index c71dce7d..e592d67d 100644
--- a/src/libcamera/include/v4l2_subdevice.h
+++ b/src/libcamera/include/v4l2_subdevice.h
@@ -35,6 +35,7 @@ public:
explicit V4L2Subdevice(const MediaEntity *entity);
V4L2Subdevice(const V4L2Subdevice &) = delete;
V4L2Subdevice &operator=(const V4L2Subdevice &) = delete;
+ ~V4L2Subdevice();
int open();
bool isOpen() const;
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index e34cc169..a03fadfd 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -112,6 +112,11 @@ V4L2Subdevice::V4L2Subdevice(const MediaEntity *entity)
{
}
+V4L2Subdevice::~V4L2Subdevice()
+{
+ close();
+}
+
/**
* \brief Open a V4L2 subdevice
*