Commit Graph

59 Commits

Author SHA1 Message Date
Barnabás Pőcze
170f31dedc pipewire-v4l2: increase reference count atomically
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.
2021-10-18 09:03:12 +00:00
Barnabás Pőcze
d21a8caace pipewire-v4l2: only access globals.file_maps while holding globals.lock
`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.
2021-10-18 09:03:12 +00:00
Barnabás Pőcze
5e1a93d61d pipewire-v4l2: only access globals.fd_maps while holding globals.lock
`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.
2021-10-18 09:03:12 +00:00
Wim Taymans
d4207d3b0c pw-v4l2: fix script as suggested by shellcheck 2021-10-14 21:14:45 +02:00
Wim Taymans
12567ea5d8 pipewire-v4l2: add enum_framesize ioctl 2021-10-14 10:16:35 +02:00
Wim Taymans
3ee852b808 pipewire-v4l2: More improvements
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.
2021-10-14 10:16:35 +02:00
Wim Taymans
8175c8276d pipewire-v4l2: more improvements
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.
2021-10-14 10:16:35 +02:00
Wim Taymans
b466fe67dd pipewire-v4l2: Implement more ioctls
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.
2021-10-14 10:16:35 +02:00
Wim Taymans
e68fd36f90 pipewire-v4l2: the start of a v4l2 LD_PRELOAD library 2021-10-14 10:16:35 +02:00