Commit graph

13610 commits

Author SHA1 Message Date
Jonas Ådahl
4ec9994bf0 pipewire/stream: Don't queue back cleared buffers
When renegotiating stream parameters (e.g. size), the buffers
are cleared should no longer be queued back. Add a flag to detect this,
while logging a warning and erroring out when the user tries to queue
such a buffer.
2025-09-10 10:19:20 +02:00
Wim Taymans
124aa40f64 alsa: use 2 (or 3 for batch) periods in IRQ mode
Some drivers (Firewire) have a latency depending on the ALSA buffer size
instead of the period size.

In IRQ mode, we can safely use 2 (or 3 for batch devices) periods
because we always need to reconfigure the hardware when we want to
change the period and so we don't need to keep some headroom like we do
for timer based scheduling.

See #4785
2025-09-10 10:18:55 +02:00
Wim Taymans
fabfdb1b01 v4l2: delay pipewire init until first openat call
Initialization of PipeWire could happen too early and deadlock in some
cases. Instead, initialize pipewire right before we're going to actually
use it for the first time.

Fixes #4859
2025-09-10 10:18:27 +02:00
Wim Taymans
0da4afca76 audiommixer: only clear mix_ops when initialized
It's possible that the mix_ops was not initialized and then the free
pointer is NULL, so check this instead of segfaulting.
2025-09-10 10:17:29 +02:00
Robert Mader
52852f66cb systemd: Allow mincore syscal for Mesa/EGL
This is required in order to allow plugins to use GL as mincore
is used in Mesas `_eglPointerIsDereferenceable()`.

One example for a client wanting to do so is the in-development
libcamera GPUISP, see https://patchwork.libcamera.org/cover/24183/
2025-09-10 10:16:24 +02:00
Wim Taymans
1efd76455f ump: make sure we set the group correctly 2025-09-10 10:15:44 +02:00
Wim Taymans
6a44b2e10f raop: write ALAC end tag
Fixes #4853
2025-09-10 10:14:57 +02:00
alexdlm
ee0809ead9 Map Razer BlackShark v3 ACP 2025-09-10 10:12:37 +02:00
Wim Taymans
f0cfe9449d tools: dump sndfile loginfo on error when verbose 2025-09-10 10:12:00 +02:00
Arun Raghavan
487c7ee933 tools: Fix -C handling for pw-dump
The short form needs to have a :: to signal an optional argument so
that something like -Calways can work.
2025-09-10 10:11:36 +02:00
Barnabás Pőcze
1c032f6ad6 pipewire: module-link-factory: cancel async work in link's destroy event
When a link enters the "ERROR" state, it is scheduled for destruction in
`module-link-factory.c:link_state_changed()`, which queues `destroy_link()`
to be executed on the context's work queue.

However, if the link is destroyed by means of `pw_impl_link_destroy()`
directly after that, then `link_destroy()` unregisters the associated
`pw_global`'s event hook, resulting in `global_destroy()` not being called
when `pw_impl_link_destroy()` proceeds to call `pw_global_destroy()` some
time later. This causes the scheduled async work to not be cancelled. When
it runs later, it will trigger a use-after-free since the `link_data` object
is directly tied to the `pw_impl_link` object.

For example, if the link is destroyed when the client disconnects:

==259313==ERROR: AddressSanitizer: heap-use-after-free on address 0x7ce753028af0 at pc 0x7f475354a565 bp 0x7ffd71501930 sp 0x7ffd71501920
READ of size 8 at 0x7ce753028af0 thread T0
    #0 0x7f475354a564 in destroy_link ../src/modules/module-link-factory.c:253
    #1 0x7f475575a234 in process_work_queue ../src/pipewire/work-queue.c:67
    #2 0x7b47504e7f24 in source_event_func ../spa/plugins/support/loop.c:1011
    [...]

0x7ce753028af0 is located 1136 bytes inside of 1208-byte region [0x7ce753028680,0x7ce753028b38)
freed by thread T0 here:
    #0 0x7f475631f79d in free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:51
    #1 0x7f4755594a44 in pw_impl_link_destroy ../src/pipewire/impl-link.c:1742
    #2 0x7f475569dc11 in do_destroy_link ../src/pipewire/impl-port.c:1386
    #3 0x7f47556a428b in pw_impl_port_for_each_link ../src/pipewire/impl-port.c:1673
    #4 0x7f475569dc3e in pw_impl_port_unlink ../src/pipewire/impl-port.c:1392
    #5 0x7f47556a02d8 in pw_impl_port_destroy ../src/pipewire/impl-port.c:1453
    #6 0x7f4755634f79 in pw_impl_node_destroy ../src/pipewire/impl-node.c:2447
    #7 0x7b474f722ba8 in client_node_resource_destroy ../src/modules/module-client-node/client-node.c:1253
    #8 0x7f47556d7c6c in pw_resource_destroy ../src/pipewire/resource.c:325
    #9 0x7f475545f07d in destroy_resource ../src/pipewire/impl-client.c:627
    #10 0x7f47554550cd in pw_map_for_each ../src/pipewire/map.h:222
    #11 0x7f4755460aa4 in pw_impl_client_destroy ../src/pipewire/impl-client.c:681
    #12 0x7b474fb0658b in handle_client_error ../src/modules/module-protocol-native.c:471
    [...]

Fix this by cancelling the work queue item in `link_destroy()`, which should
always run, regardless of the ordering of events.

Fixes #4691
2025-09-10 10:09:16 +02:00
Wim Taymans
9e8f50e3ef jack: emit port_rename callbacks
When the port is renamed, we queue a PORT_RENAME callback with an arg1
as 1. Before emitting the event we check the registered state of the
port but we want to suppress the event if the port was *not* registered,
ie. when the registered state != 1 (arg1).
2025-09-10 10:08:59 +02:00
Wim Taymans
acf463050d jack: only update port name for other ports
Don't try to check for renames of our own port, we cause that
ourselves.

Also use the name of the port to find our ports.
2025-09-10 10:08:17 +02:00
Wim Taymans
e3fd6fac49 jack: support port_rename callbacks
Look at the port name in the port_info properties and emit the
port_rename callback when it changes.

Fixes #4761
2025-09-10 10:08:06 +02:00
Wim Taymans
f5c3d0d29a midifile: fix seeking in midifile
When we perform a seek, we need to update the current position in the
file as well or we calculate wrong offsets.
2025-09-10 10:05:31 +02:00
Pauli Virtanen
165bd9965b alsa: show correct value in api.alsa.period-num 2025-09-10 10:04:30 +02:00
Wim Taymans
23b0ff136a vban: truncate sess.name when too large 2025-09-10 09:39:23 +02:00
Christian Glombek
9695fafc06 raop: don't set improper media.format 2025-08-25 12:57:24 +02:00
Christian Glombek
f81d733644 raop: set mtu to 1448 by default 2025-08-25 12:57:17 +02:00
Christian Glombek
30df4e70d0 raop: Add fp_sap25 encryption type
Add support for FairPlay SAP v2.5 (encryption type 5) type devices such as Apple Home Pod Minis.

Apparently only these devices require the `POST /feedback` heartbeat, so fix that.
2025-08-25 12:56:38 +02:00
Wim Taymans
1c542e9a0c 1.4.7 2025-07-23 17:42:58 +02:00
Wim Taymans
fefea32d9f resample: optimize phase scaling
Precalculate the constant factor to avoid a division for each sample.
2025-07-23 14:51:25 +02:00
Wim Taymans
140ae1bb62 resample: fix compilation
Also fix a compiler warning in clang
2025-07-23 14:51:11 +02:00
Wim Taymans
f04e8164a6 resample: avoid calculating GCD in rate updates
We don't actually need to calculate the GCD for each resampler rate
update. The GCD is only used to scale the in/out rates when using the
full resampler and this we can cache and reuse when we did the setup.

The interpolating resampler can work perfectly fine with a GCD of 1 and
so we can just assume that.
2025-07-23 14:50:15 +02:00
Wim Taymans
4a22b53b74 resample: reorder resample function setup
We also don't need to copy the resampler function name with each dynamic
function update, this is just for debugging.
2025-07-23 14:50:12 +02:00
Wim Taymans
a95d6dd553 alsa: update resampler requested size before reading
spa_alsa_read is called from the source process function when we are a
follower and no buffer is ready yet.

Part of the rate correction was performed by the ALSA driver when it
woke up but now, the resampler has updated the requested size and we
need to requery it before we can start reading samples.

Otherwise, we end up with requested samples from before the rate update
and we might not give enough samples to the resampler. In that case, the
adapter will call us again and we will again try to produce a buffer
worth of the requested samples, which will xrun.
2025-07-23 14:50:05 +02:00
Niklas Carlsson
5aa46bbddd filter-graph: fix index off by one in dsp_delay_c
Checking w + 1 > n_buffer means that w will go to n_buffer, which
in turn leads to reading buffer[2 * n_buffer].
2025-07-22 15:54:48 +02:00
Wim Taymans
c3ec30dec7 client-node: close SyncObj fd as well
We also need to close the SynObj fd we got, just like we close any
DmaBuf or MemFd.

Make sure we get a compiler error when we add more items to the
data type enumeration later.

Fixes #4807
2025-07-22 14:47:04 +02:00
Wim Taymans
74ad61f094 alsa: update resample state in all cases
We need to manually recheck the resample state when the matching state
got updated.
2025-07-22 14:43:37 +02:00
Wim Taymans
83fa53ba6e alsa: don't try to activate resampling with unknown rates
If the driver or our rate is not known yet, don't assume we will need to
resample.
2025-07-17 10:21:25 +02:00
Pauli Virtanen
7cd256d14c bluez5: aac: fix for A2DP v1.4 using rfa bits for more channels
A2DP v1.4 uses the rfa bits for adding 5.1 and 7.1 configurations.
Clear those bits properly when sending configuration, in case remote
device sets them.

(cherry picked from commit ae7a893ce9)
2025-07-10 17:17:22 +03:00
Arun Raghavan
7b70906162 spa: aec: webrtc: Expose echo canceller mobile_mode
Significantly better CPU performance in lieu of canceller quality. Not
implemented for 0.x series, as there's a lot more to enable there (such
as routing modes), and I am hoping to drop support for those versions
before too long.
2025-07-09 13:29:23 -04:00
Arun Raghavan
c5e90d7d51 spa: aec: webrtc: Drop outdated comment
The Intelligibility enhancer was removed, so the FIXMEs are irrelevant.
2025-07-09 13:29:21 -04:00
Arun Raghavan
5c9ddfd882 spa: audioconvert: Avoid reading past filter-graph param name end
Ensure we have at least a `.` after `audioconvert.filter-graph`, so we
don't try to read past the end if it does not exist.

Cherry-picked from a328e0ae28, dropping
the param doc update as that doesn't exist.
2025-07-09 12:14:27 -04:00
Arun Raghavan
af7ce19919 spa: aec: webrtc: Actually enable echo cancellation for 2.0 2025-07-09 15:26:11 +00:00
Jonas Holmberg
8ecdddeb04 echo-cancel: reset buffers when deactivating
Reset buffers when deactivating to avoid having old data in the
ringbuffers, which also adds latency when activated again.

Clear sink_ready and capture_ready when resetting buffers to avoid
calling process() before there is new data to process.
2025-07-09 15:26:11 +00:00
Robert Mader
8661034620 gst: pipewireformat: Validate fourcc before converting to string
gst_video_dma_drm_fourcc_to_string() asserts when called with
DRM_FORMAT_INVALID.

(cherry picked from commit 9debb4b814)
2025-07-09 17:11:43 +02:00
Jonas Holmberg
951cdf309a echo-cancel: drop if playback is not streaming
capture and sink streams may start before playback stream so process()
may fail to dequeue a playback buffer. In that case advance the read
pointers to avoid building up latency in the ringbuffers.
2025-07-07 22:32:19 -04:00
Wim Taymans
5eba752b95 echo-cancel: send capture/source latency correctly
Input latency received on the source (output stream) should be
propagated on the input stream (capture).
2025-07-07 22:32:00 -04:00
Wim Taymans
83a155d0c0 1.4.6 2025-06-27 13:16:18 +02:00
Wim Taymans
060d0e1761 Revert "loop: don't call the hooks around blocking wait"
This reverts commit 46dfa69f26.

We do actually need to release the locks for now. The reason is that
pipewire core will at various points do a blocking invoke into the
thread-loop (which is the data-loop when using non-rt/async processing)
to synchronize state. Because these functions are called with the
thread-loop lock and from some other thread (like gstreamer) it causes
a deadlock because the thread-loop is locked and can't run and the
caller is waiting for the thread-loop to complete.

See #4472
2025-06-26 12:45:29 +02:00
Wim Taymans
ff60e68a23 Revert "alsa: add Teufel Cage Pro mapping"
This reverts commit 0321f543d3.
2025-06-26 11:34:20 +02:00
Wim Taymans
c644f54ea7 audioconvert: remove unused field 2025-06-25 10:46:05 +02:00
Wim Taymans
cc94909ca1 tests: set the flags on buffers correctly 2025-06-25 10:45:59 +02:00
Wim Taymans
0fa5ceba1c audioconvert: mark output as not empty when draining
When we are draining, we use an empty input buffer but then we push out the
remaining samples out of filters and we can't assume they are empty.
2025-06-25 10:44:11 +02:00
Wim Taymans
86d1233107 alsa: don't log unknown events with info
Debug is good enough
2025-06-25 10:43:18 +02:00
Harald Sitter
0321f543d3 alsa: add Teufel Cage Pro mapping 2025-06-25 10:42:03 +02:00
Wim Taymans
a53a960645 alsa-udev: support alsa.use-ucm
Make a new alsa.use-ucm option that sets api.alsa.use-ucm on the device
it creates (when set).

There is some documentation floating around (thr arch wiki) with this
property.

See #4755
2025-06-25 10:41:51 +02:00
Wim Taymans
75034634d0 pulse-server: mark empty buffers
This makes it use some more optimal paths in the mixer.
2025-06-25 10:41:08 +02:00
Pauli Virtanen
b238060d9b doc: add links to docs of other versions 2025-06-14 12:09:46 +03:00