19#include <ossia/detail/dylib_loader.hpp>
31int v4l2_open(
const char* file,
int oflag, ...);
32int v4l2_close(
int fd);
34int v4l2_ioctl(
int fd,
unsigned long int request, ...);
35ssize_t v4l2_read(
int fd,
void* buffer,
size_t n);
36ssize_t v4l2_write(
int fd,
const void* buffer,
size_t n);
37void* v4l2_mmap(
void* start,
size_t length,
int prot,
int flags,
int fd, int64_t offset);
38int v4l2_munmap(
void* _start,
size_t length);
41namespace score::gfx::v4l2
47 decltype(&::v4l2_open) open{};
48 decltype(&::v4l2_close) close{};
49 decltype(&::v4l2_ioctl) ioctl{};
51 bool available()
const noexcept {
return open && close && ioctl; }
53 static const Libv4l2& instance()
61 : library(
"libv4l2.so.0")
63 open = library.symbol<
decltype(&::v4l2_open)>(
"v4l2_open");
64 close = library.symbol<
decltype(&::v4l2_close)>(
"v4l2_close");
65 ioctl = library.symbol<
decltype(&::v4l2_ioctl)>(
"v4l2_ioctl");
68 ossia::dylib_loader library;
75inline int retryIoctl(
int fd,
unsigned long request,
void* arg)
noexcept
77 const auto& lib = Libv4l2::instance();
81 r = lib.available() ? lib.ioctl(fd, request, arg) : ::ioctl(fd, request, arg);
82 }
while(r == -1 && errno == EINTR);
103 return ::open(path, flags);
106inline void closeDeviceRaw(
int fd)
noexcept
111inline int retryIoctlRaw(
int fd,
unsigned long request,
void* arg)
noexcept
116 r = ::ioctl(fd, request, arg);
117 }
while(r == -1 && errno == EINTR);
121inline int openDevice(
const char* path,
int flags)
noexcept
123 const auto& lib = Libv4l2::instance();
124 return lib.available() ? lib.open(path, flags) : ::open(path, flags);
127inline void closeDevice(
int fd)
noexcept
129 const auto& lib = Libv4l2::instance();
int openDeviceRaw(const char *path, int flags) noexcept
Definition V4L2Loader.hpp:101
int retryIoctl(int fd, unsigned long request, void *arg) noexcept
Definition V4L2Loader.hpp:75
Definition V4L2Loader.hpp:45