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>
This commit is contained in:
Laurent Pinchart 2019-04-17 00:37:40 +03:00
parent 889b70d62d
commit d97cafdf3c
2 changed files with 6 additions and 0 deletions

View file

@ -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;

View file

@ -112,6 +112,11 @@ V4L2Subdevice::V4L2Subdevice(const MediaEntity *entity)
{
}
V4L2Subdevice::~V4L2Subdevice()
{
close();
}
/**
* \brief Open a V4L2 subdevice
*