7.69. V4L2 select()¶
v4l2-select - Synchronous I/O multiplexing
#include <sys/time.h> #include <sys/types.h> #include <unistd.h>
select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)¶
select() function applications can suspend
execution until the driver has captured data or is ready to accept data
When streaming I/O has been negotiated this function waits until a buffer has been filled or displayed and can be dequeued with the VIDIOC_DQBUF ioctl. When buffers are already in the outgoing queue of the driver the function returns immediately.
select() returns the total number of bits set in
fd_set. When the function timed out it returns
a value of zero. On failure it returns -1 and the
errno variable is
set appropriately. When the application did not call
ioctl VIDIOC_QBUF, VIDIOC_DQBUF or
ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF yet the
function succeeds, setting the bit of the file descriptor in
writefds, but subsequent VIDIOC_DQBUF
calls will fail. 1
When use of the
read() function has been negotiated and the
driver does not capture yet, the
select() function starts
capturing. When that fails,
select() returns successful and
read() call, which also attempts to start
capturing, will return an appropriate error code. When the driver
captures continuously (as opposed to, for example, still images) and
data is already available the
select() function returns
When use of the
write() function has been negotiated the
select() function just waits until the driver is ready for a
All drivers implementing the
function or streaming I/O must also support the
For more details see the
select() manual page.
7.69.5. Return Value¶
select() returns the number of descriptors
contained in the three returned descriptor sets, which will be zero if
the timeout expired. On error -1 is returned, and the
is set appropriately; the sets and
timeout are undefined. Possible
error codes are:
One or more of the file descriptor sets specified a file descriptor that is not open.
The driver does not support multiple read or write streams and the device is already in use.
timeoutpointer references an inaccessible memory area.
The call was interrupted by a signal.
nfdsargument is less than zero or greater than
The Linux kernel implements
select()cannot return a