Commit graph

18 commits

Author SHA1 Message Date
Wim Taymans b9ace709dc pw-v4l2: clamp buffers to max
See #2029
2022-01-18 13:46:32 +01:00
Wim Taymans 35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans c387e83c65 pipewire-v4l2: avoid overflow in id calculation 2021-11-17 13:16:27 +01:00
Wim Taymans 5ed4977b38 destroy proxies when global is removed
When a global is removed, also remove the proxies. We can have multiple
proxies to a global otherwise when a client has a sequence of events
queued from the server like this:

Global 1 added
Global 1 removed
Global 1 added

The proxy we added in the firt event would not be destroyed because the
server did not know about it when global 1 was removed and then a
second one would be made.
2021-11-08 12:55:41 +01:00
Wim Taymans 9fee88239a pipewire-v4l2: only compile V4L2_BUF_CAP_SUPPORTS* when defined
Fixes #1766
2021-11-02 09:43:59 +01:00
Peter Hutterer 6fab8fabca meson: add a libv4l2-path option to match libjack-path
pw-v4l2 uses the gnu ld's ${LIB} features, see meson.build.
Make it possible to work around this by specifying an explicit path,
just like for pw-jac.

Fixes #1751
2021-10-28 07:38:02 +00:00
Arseny Maslennikov ddb38bd742 pipewire-v4l2: pw-v4l2.in: fix parameter expansion in quotes
`@LIBV4L2_PATH@` can be expanded into a string containing literally
`${LIB}`, which is then reexpanded by the shell since it's enclosed in
double quotes. We fix this by using single quotes instead.
2021-10-23 04:35:31 +03:00
Gleb Popov 35c9de34e8 Add FreeBSD variant of the ioctl request check. 2021-10-22 19:09:16 +03:00
Barnabás Pőcze 0651e12ad8 pipewire-v4l2: actually close file descriptors
Close every file descriptor of a given `struct file` object
in `v4l2_close()` apart from the "main" file descriptor.
2021-10-18 09:03:12 +00:00
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