The reference count increment in `add_fd_map()` (called from `v4l2_dup()`)
may run at the same time as `unref_file()` (called from `v4l2_close()`).
Atomically increase the refcnt to avoid any problems.
`file_map` structures are allocated in a `pw_array`. When inserting into
a full `pw_array`, it is resized to accomodate the new elements. In that case,
all `file_map` pointers may be invalidated. Hence it is only safe to access
`file_map` structs while holding `globals.lock`, which prevents any modifications
to the file map array, thus keeping the references valid.
`fd_map` structures are allocated in a `pw_array`. When inserting into
a full `pw_array`, it is resized to accomodate the new elements. In that case,
all `fd_map` pointers may be invalidated. Hence it is only safe to access
`fd_map` structs while holding `globals.lock`, which prevents any modifications
to the fd map array, thus keeping the references valid.
Keep separate map for fd to files so we can implement dup.
Filter out duplicates in enumfmt.
tryfmt should return the closest match.
Use pthread_once to init the global state.
Make things mostly work in GStreamer.
Add support for more formats.
Connect in the reqbufs ioctl so that we can negotiate the right amount
of buffers.
Keep file and buffer maps so that we can map an address to a file and
then the address to a buffer of that file. We can then also check if the
buffers were unmapped properly.
Implement some more ioctls.
Add some more checks.
Collect all video/source nodes and enumerate their formats. We use this
to return the supported formats and to check if a format is supported.
Use evenfd as the even we return from open. Make the eventfd readable
when we have a new buffer ready.
Connect a stream when setting a format. Collect buffers. Implement
mmap/munmap on the buffer memory. Implement queue and dequeue of buffers.
This is enough to make the webcam test work in firefox.