From cfe4f9622ead96702d879835ca9dd2942d503399 Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Thu, 10 Jun 2021 16:50:23 +0900 Subject: libcamera: v4l2_device: Use UniqueFD for a file descriptor Manages a file descriptor owned by V4L2Device for a v4l2 device node by UniqueFD. Signed-off-by: Hirokazu Honda Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- include/libcamera/internal/v4l2_device.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include/libcamera/internal') diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 7816a290..8886b750 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -27,7 +28,7 @@ class V4L2Device : protected Loggable { public: void close(); - bool isOpen() const { return fd_ != -1; } + bool isOpen() const { return fd_.isValid(); } const ControlInfoMap &controls() const { return controls_; } @@ -49,11 +50,11 @@ protected: ~V4L2Device(); int open(unsigned int flags); - int setFd(int fd); + int setFd(UniqueFD fd); int ioctl(unsigned long request, void *argp); - int fd() const { return fd_; } + int fd() const { return fd_.get(); } private: static ControlType v4l2CtrlType(uint32_t ctrlType); @@ -72,7 +73,7 @@ private: ControlIdMap controlIdMap_; ControlInfoMap controls_; std::string deviceNode_; - int fd_; + UniqueFD fd_; EventNotifier *fdEventNotifier_; bool frameStartEnabled_; -- cgit v1.2.1