Commit graph

12674 commits

Author SHA1 Message Date
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
Wim Taymans
32956efbf7 spa-node: always set clock.quantum-limit property
Set the clock.quantum-limit property on the node also when it was
created without properties.

Fixes clock.quantum-limit on the Midi-Bridge.

See #4005
2024-08-06 17:50:19 +02:00
Wim Taymans
d5298eee2c module-ffado: implement freewheeling
When freewheeling starts, pause the streaming and resume when
freewheeling stops. Also make sure we don't try to do any IO or
timeouts.
2024-08-06 17:49:54 +02:00
Wim Taymans
d6d08997bb module-ffado: separate rt booleans from non-rt 2024-08-06 17:49:47 +02:00
Wim Taymans
bcd2062dcf conf: increase priority of dummy and freewheel driver
We have various modules that set the priority higher than the dummy and
freewheel driver (ffado, netjack,...). This makes it impossible to use
the freewheel driver on them.
2024-08-06 17:49:29 +02:00
Wim Taymans
dee3fd2037 modules: use the right module name in the docs
Fixes #4172
2024-08-01 12:35:06 +02:00
Arun Raghavan
ccd68990ad alsa-pcm: Lower the frequency of USB gadget rate updates
While the spec allows for 1ppm changes, our rate matching logic applies
these changes quite often, which can be spammy on USB. I haven't seen
hosts mind this, but it seems like it might be a problem at some point.

Additionally, if we also have bind ctls enabled, every pitch update is
also a wakeup for ourselves (whether or not we're listening for the
pitch ctls, since the mixer fd does not distinguish between ctls, those
are filtered after we wake up).

The 10ppm threshold is empirically tested as being not "too noisy" (i.e.
when updates happen, I can see them scroll by with `amixer events`).

If necessary, we can make this configurable in the future.
2024-08-01 12:34:57 +02:00
Dylan Aïssi
75cc639593 meson: allow fallback to find_library for readline detection
Fixes: 050a51aa (" meson_options: Add readline option")

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
2024-08-01 12:34:51 +02:00
Wim Taymans
7ceca29970 pw-cli: support arbitrary large params and commands
Use a memstream to collect the arguments so that it can dynamically
allocate as much memory as necessary.

Use a dynamic pod builder to construct the pods so that they can be of
arbitrary size.

Fixes #4166
2024-08-01 12:34:41 +02:00
Wim Taymans
86287760a0 module-ffado: add some docs 2024-08-01 12:34:32 +02:00
Wim Taymans
afc0e6e69d module-ffado: keep the configured rate in sync with params
When we reconfigure rate, make sure we update the EnumFormat and Format
params with the new value.
2024-08-01 12:34:24 +02:00
Wim Taymans
270470987d module-ffado: Improve samplerate and periodsize handling
Only set use the graph rate and duration when the ffado.sample-rate
and ffado.period-size properties are set to 0. Othersize use the
configure values.

Without this patch, it would just ignore the settings and always use the
graph rate.
2024-08-01 12:34:16 +02:00
Wim Taymans
e224ccdcb7 1.2.2 2024-07-31 12:02:24 +02:00
Wim Taymans
9f2ac1f55d jack: remove leftover debug 2024-07-31 12:01:40 +02:00
Wim Taymans
8d0c7c6e67 impl-node: include config.h to define HAVE_MALLOC_TRIM
It was previously not used..
2024-07-30 18:01:10 +02:00
Wim Taymans
7392e4df1b impl-node: reset pending state when moving driving node
Commit d04a28daef moved the configuration
of the IO_Position after we removed the node from the old driver but
forgot to move the code that updates the pending_state.

See #4094
2024-07-30 18:01:08 +02:00
Wim Taymans
25fbcae1b3 loop: release queue lock before calling invoke function
We don't actually need to hold the lock while calling the invoke
function, we only need the lock to protect the list of queues.
2024-07-30 18:01:01 +02:00
Wim Taymans
0d7c20760e impl-port: improve IO_Buffers management on ports
Make sure we clear IO_Buffers on the port and mixer before we clear the
buffers or the format. The IO_Buffer is used to check if the port should
be processed or not and its update is synchronized with the data-thread.

Set IO_Buffers on the mixer and node only after we have configured the
buffers on the node.

See #4094
2024-07-30 09:46:59 +02:00
Wim Taymans
628f292fb8 audioconvert: set IO_Buffers only when buffers are negotiated
The IO_Buffers is used in the data thread to check if the port should be
scheduled or not. Make sure it is only set after we set buffers on the
port and cleared before the buffers are cleared.

Make sure we sync the port->io with the data thread.

See #4094
2024-07-30 09:46:52 +02:00
Vlad
ba17264bdb bluez5: Update default sync_factor
Due to the how the kernel part of BlueZ computes the extended
advertising interval for a Broadcast Source, a sync_factor smaller
than 2 will result in an invalid interval value (too small).
2024-07-29 10:29:25 +02:00
Wim Taymans
d0d7e87588 modules: fix doc
Fixes #4134
2024-07-29 10:28:36 +02:00
Wim Taymans
e56939ac0f impl-link: make async link when on e of the nodes is async
We simply cannot schedule async nodes properly if we don't have the
async link. This change was done to make sure that driver sources don't
end up with async buffers and cause a unneccesary 1 cycle delay in
async clients. But we can fix this in a better way, like this:

Increment the cycle counter after we copy the output port buffers. This
ensures the async clients immediately pick up the new buffers (or the
output buffers from the previous cycle).

Also remove some old compatibility code that is no longer useful.

Fixes #4138
See #4133
2024-07-29 10:28:22 +02:00
Wim Taymans
b3688b163d loop: signal when queue is full
When our queue is full, signal the wakeup event to make sure the thread
will wake up and try to clear the queue before we go to sleep.
2024-07-29 10:27:35 +02:00
Wim Taymans
77147c9cd7 module-rtp: fix ptime and target_buffer checks
target_buffer is in samples and ptime in msec so we can't really compare
them. Use psamples instead, which is ptime but then as samples.

See #4095
2024-07-29 10:27:02 +02:00
Wim Taymans
7758bb2bb7 jack: jack_get_time() returns microseconds
As found by David García Goñi

Fixes #4128
2024-07-29 10:26:24 +02:00
Wim Taymans
b86ac34deb jack: don't check timestamps in mixdown
jack_port_get_buffer() can be called with 0 frames, This is to restrict
the available space in the returned midi buffer after mixdown. While we
mixdown, we should not check timestamps so that all midi events are
added to the mixdown buffer.

Fixes qsynth.
2024-07-29 10:26:13 +02:00
Wim Taymans
ad9dc1ec81 modules: don't unload module on stream error
Unloading the module on stream errors is a bit too much because a
suspend can clear the stream error again (or the error might not be
fatal)

This can happen for example when negotiation fails on some stream ports
(wireplumber tries to link the midi ports to audio ports) and it's
better to not completely fail on that.

Fixes #4121
2024-07-18 14:27:54 +02:00
Wim Taymans
08d14b7d51 impl-node: always INACTIVATE when stopping
A remote node is prepared when the Start command sync reply has been
received.

If we however quickly switch from active to inactive, the
pending reply is cancelled but the remote node will have set the
FINISHED status and will be ready to be scheduled.

Make it so that we always set the INACTIVE status when the node is
canceled and unprepared, even if we didn't get the reply and the node
was not prepared.

Fixes #4122
2024-07-18 14:27:16 +02:00
Daniel Lundqvist
4902646e73 module-jack-tunnel: Properly propagate error from dlopen()
dlopen() does not set errno on failure, rather you're supposed to call
dlerror() to get the latest error. dlerror() return a string so
instead return -ENOENT from weakjack_load_by_path().

Depending on errno weakjack_load() could think it successfully loaded
the library, and later module-jack-tunnel would crash because it call
a NULL function pointer.
2024-07-18 14:27:01 +02:00
Frédéric Danis
b19c3501e7 bluez5: backend-native: Send error for not supported event only as AG
The HS/HF roles should not sent error messages, only commands.
2024-07-18 14:26:32 +02:00
Pauli Virtanen
9478414773 alsa-card-profiles: revert HDMI/AC3 profiles
They don't work on all HDMI output devices, and availability is
not detected so they're available also when they don't work.

Selecting the profiles on non-working devices results to

spa.alsa: plug:{SLAVE="a52:0,'hw:0,3'"}p: snd_pcm_start: Broken pipe

and noise output to speakers. Revert these profiles from stable branch
for now as the break things.

This reverts commit 916d2cdb28.
This reverts commit d6c17681da.
2024-07-14 12:01:31 +03:00
Wim Taymans
1ba71c1be2 node-driver: 5 seconds of freewheel timeout is enough
We retry to run the graph every 5 seconds in case it didn't complete. A
10 seconds timeout feels quite long.
2024-07-12 12:30:42 +02:00
Wim Taymans
5f934b2b95 node: add a clock XRUN_RECOVER flag
Make a new flag that is set when the process function is called because
of a recover from a graph xrun.

Use this flag in the freewheel driver to detect a recover and to avoid
scheduling a new timeout. We should schedule a new timeout only when the
process function was called after completion.

This fixes export in ardour some more when the initial driver timeout
didn't complete (when, for example, some nodes were still starting up).
2024-07-12 12:30:37 +02:00
Eli Schwartz
3e210e4cf2 meson: fix conflicting use of feature-based dependency lookups
When spa-plugins is enabled, the gio-2.0 global dependency is
overwritten.

When bluez support is enabled, OR when gsettings is enabled, the gio-2.0
dependency is then detected as found. This means that
pipewire-module-protocol-pulse can end up enabling gsettings support
even if it has been forcibly turned off.

Rename the meson variables to ensure they are looked up separately.
2024-07-12 10:28:29 +02:00
Wim Taymans
f9689df37d 1.2.1 2024-07-12 09:24:23 +02:00
Wim Taymans
d55f5ef608 module-raop: remove unused deprecated header 2024-07-12 08:58:43 +02:00