Commit graph

12709 commits

Author SHA1 Message Date
Wim Taymans
497c2b7bc5 jack: use the CPU max_alignment
Instead of aligning the buffers to 16 bytes, use the CPU max_align
value (32 on intel).

Move the mix function from a static global variable to a per client
member because this could change per client.
2024-09-27 09:49:18 +02:00
Wim Taymans
3ef6acdfb1 spa: avoid C23 empty initializers in the headers
Patch by Petar Popovic to avoid using empty initializers in headers.

Fixes #4317
2024-09-25 10:56:30 +02:00
Alper Nebi Yasak
351bc9ac3c acp: sync the mixer after selecting the port
Otherwise we might sync the wrong port and end up muted.

Fixes #4084
2024-09-25 10:18:33 +02:00
Wim Taymans
5bed12569d jack: Improve transport BBT handling
The bar can start from 0 in JACK.

Add bar_start_tick and ticks_per_beat to the io_segment_bar so that we
can losslesly store the complete jack BBT values.

See #4314
2024-09-25 10:18:15 +02:00
Wim Taymans
b34a97017d impl-link: also handle unprepared active links
An ACTIVE link going to < PAUSED is unprepared.
2024-09-25 10:17:45 +02:00
Wim Taymans
77649f560c docs: update pw-cli docs for do_link
Fixes #4272
2024-09-25 10:17:32 +02:00
Gleb Popov
7e789d05ec Fix test-functional compilation by including necessary header 2024-09-25 10:16:39 +02:00
Gleb Popov
a4bcd2a193 Fix test-loop on FreeBSD by linking to epoll-shim 2024-09-25 10:16:30 +02:00
Gleb Popov
bdbf3c563b Use if_indextoname() instead of less portable ioctl(SIOCGIFNAME) 2024-09-25 10:16:16 +02:00
Gleb Popov
49246d44e3 Move the ifr_ifindex FreeBSD definition into a header file to reduce code duplication 2024-09-25 10:16:08 +02:00
Gleb Popov
1a73424f13 Include <pthread_np.h> on FreeBSD to access pthread_setaffinity 2024-09-25 10:15:49 +02:00
Gleb Popov
06c9d090e6 meson: Search for and link to stdthreads 2024-09-25 10:15:43 +02:00
Gleb Popov
a3c13db75d Use the 'thrd_success' constant when checking for tss_create result 2024-09-25 10:12:42 +02:00
Wim Taymans
bf4bb9fcc1 json-pod: return errors from spa_json_next()
Instead of silently ignoring the error and continuing.

See #4313
2024-09-25 10:12:35 +02:00
psykose
ba44236f8f ci: add elogind to alpine CI
this should now be picked up, so add it to make sure elogind is checked in CI
2024-09-25 10:11:31 +02:00
psykose
cc5a4a97fe spa: use a separate logind dependency separate from systemd
non-systemd systems also have logind, in the form of elogind, which works to
resolve the v4l2 video source race just as well. permit finding elogind, by
using a separate dep object.
2024-09-25 10:11:13 +02:00
Wim Taymans
2113425b8e modules: don't assume network addresses are numeric
There is no reason to disallow hostnames.

Fixes #4292
2024-09-25 10:08:41 +02:00
Barnabás Pőcze
4930646ff2 spa: alsa: avoid potential uninitialized variable use
In both funtions `ctl_hndl` could be passed to `snd_ctl_close()`
while being unitialized if `this->device_info.change_mask` is zero.
2024-09-25 10:08:22 +02:00
Wim Taymans
3937f03f04 impl-node: only process RequestProcess after state change
Wait until we are in the RUNNING state before sending
RequestProcess.
2024-09-20 09:39:55 +02:00
Wim Taymans
5695fda57c 1.2.4 2024-09-19 11:34:05 +02:00
Robert Mader
a1418589a7 gst: Stop trying to use DMA_DRM with MOD_INVALID
GSTs DMA_DRM API does explicitely not support implicit modifiers and
trying to use it would result in assertions like
```
gst_video_dma_drm_fourcc_to_string: assertion 'modifier != DRM_FORMAT_MOD_INVALID' failed
```

Fixes: f1b75fc6f ("gst: Add support for DMA_DRM / explicit modifiers")
2024-09-17 12:07:24 +02:00
Wim Taymans
1e7aef5600 impl-node: only let the server send RequestProcess commands
When we emit the RequestProcess event from an exported node, don't
send the RequestProcess command to ourselves but let the server
decide where to send it to.
2024-09-17 12:07:09 +02:00
Hans de Goede
4c29ea4f6f spa: v4l2: Fix v4l2 SPA not working on camera with relative controls
Some V4L2 controls like focus, pan or tilt can be relative (change
the lens / angle relative to previous positions) these return EACCES
when calling VIDIOC_G_CTRL on them.

Fix the v4l2 SPA not working on cameras with relative controls,
such as e.g. the Logitech QuickCam Orbit MP.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-09-17 12:07:03 +02:00
Wim Taymans
c6ae68b932 adapter: also forward the RequestProcess events 2024-09-17 12:06:42 +02:00
Philippe Normand
42df643e0c meson: Fix typo in GStreamer dependencies mapping
Without this the device provider cannot be enabled when building PipeWire as a
GStreamer subproject.
2024-09-17 12:05:53 +02:00
Arun Raghavan
eb7be3331f module-rtp-sap: Make sure we don't publish a null refclk
If the PTP refclk is not readable, we fallback to the stored ts_refclk,
which might be NULL. Make sure we check for this case.
2024-09-17 11:58:12 +02:00
Wim Taymans
75b428ea55 jack: emit buffer_size during jack_activate()
JACK emits the bufsize callback from the processing thread while
jack_activate() is called. Do the same with a blocking invoke.

The GStreamer plugin relies on this and when it reives the bufsize
callback later, it will error out.

Fixes #4260
2024-09-17 11:57:42 +02:00
Stefan Ursella
2c905fc548 alsa-pcm: unlink pcm when driver is changed to a different pcm
We have to unlink pcms when they are linked to a driver from
a different pcm.

When a playback and a capture pcm is linked and we start
the playback pcm and the capture pcm later this can leads
to a 'EPIPE' error on the capture device.

...
spa.alsa: hw:3,0c: snd_pcm_start: Broken pipe
...
2024-09-17 11:56:35 +02:00
Wim Taymans
0377a3797a global: avoid recursive destroy calls
Fixes #4250
2024-09-17 11:55:54 +02:00
Wim Taymans
f9eed5843c v4l2: queue dropped first buffer again
When we drop the first buffer to avoid timestamp problems, queue it
again in the driver or else we will not be able to dequeue is again
later and we will be running with a buffer less.
2024-09-17 11:55:36 +02:00
Wim Taymans
b807348041 format: SPA_POD_Fraction takes a pointer to a fraction 2024-09-17 11:55:14 +02:00
Hans de Goede
2cbbc4e7ac spa: v4l2: Use systemd-logind to listen for access changes
There is a race between logind applying ACLs to allow the active session
of a locally present user access to devices with a udev uaccess tag
(like /dev/video# nodes) getting applied vs wireplumber/pipewire starting.

Wireplumber/pipewire are part of the (user) default.target, which gets
started as soon as a user logs in and systemd --user is started for that
user, where as logind only starts applying the ACLs after the gnome-shell
associated logind session has been created.

This race may cause pipewire to not see v4l2 video sources at login,
this can be reproduced with these steps:

1. sudo setfacl --remove-all /dev/video*
2. systemctl --user restart pipewire
3. Now wp-ctl status will not show any video devices
   (like if pipewire was started before the udev uaccess ACLs got applied)
4. Do a switch to another (test) user without logging out, e.g. in GNOME
   go to the top right system menu press the power on/off icon and select
   "Switch User..."
5. Switch back to your normal user. Run getfacl /dev/video0 this will show
   your user has access now.
6. wp-ctl status should show the camera now, but it does not.

Fix pipewire not seeing v4l2 sources in this case by making v4l2-udev
monitor systemd-logind session changes and redoing the access() checks
on /dev/video# nodes when the session changes.

Closes: #3539
Closes: #3960
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 2a6ba61264)
2024-09-11 15:33:14 +02:00
Hans de Goede
0b54e568fa spa: v4l2: Remove start_inotify() call from impl_on_fd_events()
The spa_loop_add_source() call for udev event monitoring which uses
impl_on_fd_events() is done from start_monitor() which also unconditionally
calls start_inotify().

Since start_monitor() already always calls start_inotify() there is no
scenario where start_inotify() has not been called yet when
impl_on_fd_events() gets called. So the start_inotify() call in
impl_on_fd_events() is redundant, remove it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit ab245947e5)
2024-09-11 15:33:04 +02:00
Robert Mader
dcf2d8f103 libcamera: reset ringbuffer when clearing buffers
Keeping the ringbuffer state around resulted in a high chance of
using wrong buffer IDs for consequent streams, causing various issues.
2024-08-30 18:36:04 +02:00
Wim Taymans
16a7467815 tools: try to parse float values better
First try to parse the float value as a JSON number and then fall
back to atof to get the locale dependent variant.

This transparently makes things work with values such as 0.5 and 0,5.

Fixes #4234
2024-08-30 18:35:45 +02:00
Wim Taymans
e2a76824e2 1.2.3 2024-08-22 09:50:50 +02:00
Wim Taymans
6dca90fa26 Revert "spa: support: loop: do not call control hooks on blocking invoke"
This reverts commit 9ae89b4247.

All invokes should be paired with a lock/unlock if the loop requires
this. For internal calls of invoke, this will also be true because all
pipewire functions should be called with the lock.

Fixes #4215
2024-08-21 16:30:48 +02:00
Barnabás Pőcze
98c9d13973 impl-link: fix error message memory leak
`pw_link_info::error` was previously not cleared when a link was destroyed,
leading to a memory leak if an error message had been set. For example,
if format negotiation fails, and as a result the link is destroyed.
2024-08-21 11:50:48 +02:00
Severin von Wnuck-Lipinski
cdc85a0d2d bluez5: backend-native: Handle AT+CCWA command
Claim that call waiting notifications are supported.
Required for some devices (e.g. Soundcore Motion 300),
as they stop sending commands if the reply to CCWA is not OK.
2024-08-21 11:50:48 +02:00
William Wedler
20529edf82 pw-top: Limit length of formatted shortname to resolve build error
Resolves:

"error: ‘%s’ directive output may be truncated writing likely 33 or more bytes into a region of size 10 [-Werror=format-truncation=]""
2024-08-21 11:50:48 +02:00
Wim Taymans
074ad04f16 impl-node: Do xrun check a bit better
Check if the node is FINISHED instead of checking the refcounts. It's
possible that the refcounts are 0 but the node was not scheduled or
finished yet.

If the node is not FINISHED but TRIGGERED, we can run the recover
without reporting an error.

Any other state is an error and we need to log this and recover.

See #4182
2024-08-21 11:50:44 +02:00
Wim Taymans
f1b6a62d8b impl-node: always INACTIVATE a node when stopping
Set the node state INACTIVE on the client and server side in all cases
when stopping to ensure nothing tries to schedule the node anymore.
2024-08-21 11:44:10 +02:00
Wim Taymans
1bd4d21142 impl-node: improve debug
Use ATOMIC_LOAD to get status.
Debug the pending state after decrementing so we debug the value we
are actually going to test.
Add node id to debug lines to better track things.
2024-08-21 11:43:53 +02:00
Wim Taymans
647237b955 impl-node: improve xrun debug
Debug the xrun state before we change things and run the recovery
process.
2024-08-21 11:43:14 +02:00
Wim Taymans
50e14194c0 impl-node: don't overwrite node state when finished
Don't just overwrite the state with FINISHED but only do this when the
state was AWAKE.

The server might already have started a new cycle and placed
NOT_TRIGGERED as the state. Or, it might have changed the state to
INACTIVE. In all cases, we should not overwrite the state unless it was
AWAKE and we should only trigger peers when we were AWAKE.

This fixes some spurious xruns and glitches.

See #4182
2024-08-21 11:43:04 +02:00
Hans de Goede
a46e74ba05 spa: v4l2: Remove start_watching_device() loop from start_inotify()
Now that start_monitor() (which calls start_inotify()) is called before
enum_devices() it no longer is necessary to call start_watching_device()
for devices which have been enumerated before start_inotify() gets
called (since there will not be any such devices anymore).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-08-21 11:41:47 +02:00
Hans de Goede
3dc03b361d spa: v4l2: call start_monitor() before enum_devices()
This fixes 2 races wrt probing v4l2 devices:

1. Before this change there was a window where a new udev device can get
added between the udev_enumerate_scan_devices() call in enum_devices() and
the udev_monitor_enable_receiving(this->umonitor); call. If this window was
hit then enum_devices() would not see the device and no udev-event for it
would be received either causing the device to not be seen.

Enabling udev event monitoring before calling udev_enumerate_scan_devices()
fixes this. Note that the code is already prepared to deal with getting
multiple add/change events for the same udev device, so hitting the new
race window where PipeWire may receive both an add- or change-event and
also sees + probes the device from enum_devices() is not a problem.

2. Before this change devices added by enum_devices() would not have
inotify monitoring activated right away because notify.fd = -1 at this
time turning start_watching_device() into a no-op.

These devices without inotify monitoring would then have their access
checked by process_device() calling check_access().

Then after all devices have been enumerated start_monitor() would call
start_inotify() which calls start_watching_device() for all devices added
by enum_devices(). This leaves a window where the ACL can change without
there being an inotify watch for it.

Calling start_monitor() before enum_devices() puts start_inotify()
notify before enum_devices() so that the add_device() calls done
by enum_devices() will now successfully call start_watching_device()
closing this window.

PipeWire is somewhat likely to not notify ACL changes because of this
because PipeWire is part of the systemd user default.target, where as
logind only starts applying the ACLs after GNOME has created the seat
for the GNOME session. So on first login we have PipeWire starting
and logind applying the ACLs at the same time, which allows for the ACL
change to hit the small race window where PipeWire is not monitoring
for ACL changes. Fixing this second race should hopefully resolve
issue #3960.

Closes: #3960
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-08-21 11:41:40 +02:00
Hans de Goede
a31cbef289 spa: libcamera: Increase devices_str[] buffer size
Some complex camera pipelines, like the IPU6 can involve many /dev/video#
nodes (32 in the IPU6 case) and the current size of 128 chars is not enough
to hold all /dev/video# nodes in this cases causing SPA_KEY_DEVICE_DEVIDS
to get truncated, which in turn breaks the filtering of V4L2 devices which
are used by a libcamera driven camera in wireplumber.

Fix this by increasing the size of devices_str[] to 256.

This fixes wireplumber adding a bunch of non-function V4L2 video sources,
e.g. before this "wpctl status" outputs the following video sources:

Video
 ├─ Devices:
...
 ├─ Sources:
 │      90. ov2740
 │  *  115. ipu6 (V4L2)
...
 │     135. ipu6 (V4L2)
 │
 ├─ Filters:

After this fix the output is:

Video
 ├─ Devices:
...
 ├─ Sources:
 │  *   92. ov2740
 │
 ├─ Filters:

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-08-06 17:51:07 +02:00
Wim Taymans
2f3276f6bb loop: don't usleep when queue is full
When the queue is full, before this patch we used to go into usleep in
the hope that the other thread will run and empty the queue and that we
can retry after the usleep.

This however does not always work because the other thread might be waiting
for the thread that does the invoke call and we lock forever.

Therefore we should always try to make progress in some way. Instead of
waiting, allocate an (or use the previously allocated) overflow queue and
write to that one. We can chain multiple overflow queues together as many
as we need (but we might want to bound that as well).

The loop.retry-timeout property is now deprecated.

See #4114
2024-08-06 17:50:58 +02:00
Barnabás Pőcze
5fed160972 spa: support: loop: do not call control hooks on blocking invoke
The control hooks of a loop are called before the loop starts polling
and after it has finished polling. Currently, this is used to implement
the locking in pw_thread_loop. This is used to guarantee that the thread
loop's lock is taken while the thread loop is dispatching, and that
the lock can be taken while the loop is polling, when it is running
no user-space code.

However, calling the thread control hooks of thread A when doing an
blocking invoke from thread B serves little purpose, and in fact
can cause issues: for example, issuing a blocking invoke on a
pw_thread_loop does not work unless the lock thereof is taken.

This behaviour, of calling the control hooks from other threads,
is also not documented, and goes contrary to what is currently
stated in the loop.h header file:

  /** Executed right before waiting for events. It is typically used to
   * release locks. */
  ...
  /** Executed right after waiting for events. It is typically used to
   * reacquire locks. */

At the moment the implementation allows any thread to queue invoke
items on any other thread without restrictions; calling the control
hooks only places extra restrictions on the usability of this mechanism
(in case of pw_thread_loop, having to take the loop's lock).
So do not call the control hooks when doing a blocking invoke.
2024-08-06 17:50:38 +02:00