Commit graph

14648 commits

Author SHA1 Message Date
Pauli Virtanen
7dd2c60b12 bluez5: synchronize transport state after acquire of an acquired transport
With keepalive enabled, we need to emit state change event on acquire
similarly as we do if refcount was already positive.

Co-authored-by: Martin Geier <martin.geier@streamunlimited.com>
2026-02-14 12:03:07 +02:00
Alexander Sarmanow
63129dd3dc fixup 2026-02-13 17:16:18 +00:00
Alexander Sarmanow
5c9b3ee05a bluez5: bap: use BD address for per-adapter BIG config
HCI indexed names are not stable. The adapters BD address is here a
better approach to map the configuration.
2026-02-13 17:16:18 +00:00
Alexander Sarmanow
5f12dd99a3 bluez5: add adapter reference to remote_endpoint
This should make adapter members easier accessible via remote endpoints.
2026-02-13 17:16:18 +00:00
lumingzh
b0b6f6ca37 update Chinese translation 2026-02-13 09:40:40 +08:00
Jonas Holmberg
ca4fa88598 context: set time in position for drivers
Set time in position for drivers to make sure an old time isn't copied
by followers before the driver is started.
2026-02-12 17:15:33 +01:00
Wim Taymans
7f08c0d404 doc: fix a typo 2026-02-12 13:46:04 +01:00
Wim Taymans
11d5e071ec stream: return -EIO when doing get_time in != STREAMING
The stream should be streaming before the get_time call is meaningful.

Various places in the code already check this an fall back to a default
value, we just need to return an error here.
2026-02-12 12:26:33 +01:00
Pauli Virtanen
12fb9ab831 bluez5: use correct A2DP profile in codec switch
We can only switch within currently connected A2DP profiles, as
generally remote endpoints are available only for the connected ones.
2026-02-11 18:53:32 +02:00
Wim Taymans
47de1e15a4 channelmix: handle more than 64 channels
When setting up the mix matrix, don't just iterate over the first 64
(CHANNEL_BITS) positions because then we will never be able to configure
more than 64 channels in the matrix.

Instead iterate until we have filled all src and dst entries in the
matrix. For the first 64 positions we might need to check the channel
mask to get the right positions in our source matrix.

Fixes the channel mixer for >64 channels where the positions above 64
where 0 in the matrix and muted.

Fixes #5118
2026-02-10 13:34:44 +01:00
Wim Taymans
494d727108 channelmix: improve debug
Instead of printing lines and lines of numbers, format everything as
a matrix. Only do the work when debug is enabled.
2026-02-10 13:18:01 +01:00
Wim Taymans
a2df282086 pw-cat: add a container option and some --list options
Add a container option to override the extension check and force a
container when saving.

Add some more formats that are supported by libsndfile.

Add some options to list all supported formats, extensions/containers,
layouts and channel names.

Fixes #5117
2026-02-09 13:55:52 +01:00
Frédéric Danis
0470f96887 bluez: bap: Select correct settings for select_config()
Depending on the codec kind, select appropriate settings to pass
to select_config().

This allows to pass the bluez5.bap.force-target-latency property,
and so to select the same configuration.
2026-02-09 09:27:10 +00:00
Frédéric Danis
c499255098 bluez5: bap: Add device property to force target latency
Some PTS tests (e.g. BAP/UCL/SCC/BV-046-C or BAP/UCL/SCC/BV-077-C)
requests to select QoS from low-latency or high-reliabilty.

The bluez5.bap.force-target-latency device property allows to force it.
For other values than low-latency or high-reliabilty the QoS selection
will use both tables to find the more appropriate configuration.
2026-02-09 09:27:10 +00:00
Barnabás Pőcze
2770143f50 gst: pool: fix buffer release race condition
A call to `release_buffer()` may happen in a gstreamer thread concurrently
with the pipewire stream emitting the `remove_buffer` event in the thread
loop, which, in pipewiresink calls `gst_pipewire_pool_remove_buffer()`, which
in turn modifies the `GstPipeWirePoolData` object. Thus a data race occurs
when accessing its members, which can lead to `pw_stream_return_buffer()`
being called with a null pointer.

Fix that by locking the thread loop before checking the conditions.

Fixes: c0a6a7ea32 ("gst: handle flush event in pipewiresink")
2026-02-09 09:25:36 +00:00
Stanislav Ruzani
64e0a9cbd9 alsa-pcm: set rate_match rate to 1.0 when not matching
Only set rate_match rate to DLL correction when matching is active.
When ALSA is driver and not matching, set rate to 1.0 to indicate no rate adjustment needed.
DLL still runs for buffer level management but rate_match should not expose correction
when matching is inactive to avoid confusion during debugging.

Signed-off-by: Stanislav Ruzani <stanislav.ruzani@streamunlimited.com>
2026-02-05 10:45:11 +01:00
Carlos Rafael Giani
bac776f8b4 doc: spa: Explain the nsec and next_nsec values in the driver docs better 2026-02-05 10:34:32 +01:00
Pauli Virtanen
84bfbd92a1 bluez5: bap: prefer high-reliability qos for 44.1/48 kHz
On some device combinations (MT7925 / Sony LinkBuds S) the low-latency
48 kHz QoS crackle.

It's probably better to default to high-reliability for those, until we
have proper quality vs. latency configuration in place.
2026-02-03 19:10:25 +02:00
Hugo Osvaldo Barrera
57efceeb02 Implement socket activation without libsystemd
Socket activation uses sd_listen_fds from libsystemd, and can only be
compiled on systems with systemd.

This is an issue for Alpine / postmarketOS, where upstream has no
systemd package, but downstream depends on upstream's pipewire package
and wants to rely on socket activation. This also prevents using
socket-activation on other non-systemd distributions, including
non-Linux.

Implement equivalent functionality without a dependency on libsystemd.
2026-02-03 13:17:59 +01:00
Wim Taymans
2c0988ab4c bluez-dbus: fix adapter memcpy length
sizeof(adapter) is larger than the big_entry->adapter and so the code
would copy too much. Instead only copy the strlen of the parsed
adapter, which we checked above to be smaller than the available size.

This doesn't copy the 0 byte because the memory is assumed to be 0
filled already by the calloc.

If the address is exactly the HCI_DEV_NAME_LEN, it will result in a non-0
terminated string, which may or may not be a problem...
2026-02-03 10:16:22 +01:00
Wim Taymans
ac7728097f snapcast: support newer snapcast service type
Newer snapcast servers publish the service as _snapcast-ctrl._tcp so
listen for that as well.

Fixes #5104
2026-02-03 10:01:38 +01:00
Carlos Rafael Giani
642504f5f9 module-rtp: Compensate for stream resampler effects in RTP sink node 2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
6192c11038 module-rtp: Convert clock pos to RTP time in RTP source and factor in ASRC
This can easily be overlooked if the RTP rate equals the clock rate, which
is fairly common (for example, RTP rate and clock rate both being 48 kHz).

And, if an ASRC is active, and converting the output of the RTP source
node, the resampler's delay need to be taken into the account as well.
2026-02-03 09:07:48 +01:00
Stanislav Ruzani
e874f705a9 module-rtp: clear ringbuffer when stream stops to prevent old packets
Clear the ringbuffer in stream_stop() when processing stops to prevent old invalid packets
from being sent when processing resumes via rtp_audio_flush_packets().

This ensures a clean state when the stream restarts.
2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
a16485f8aa module-rtp: Extract common RTP code into static library for better reuse 2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
5d7f21f130 module-rtp: Improve rtp_audio_flush_packets() logging 2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
9f0dc9c1af module-rtp: Update ringbuffer indices upon resync with proper API calls 2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
543000151f module-rtp: Handle unsigned 32-bit integer overflow in constant delay mode 2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
413f5762c4 module-rtp: Clear ringbuffer in constant delay mode
Clearing the ring buffer is important not only in the direct timestamp
mode, but also in the constant delay mode, since missed packets can lead
to gaps in the ring buffer. These gaps may have stale data inside if the
ringbuffer is not cleared after reading from it.
2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
95970e539e module-rtp: Fix invalid ring buffer read attempts in direct timestamp mode
In corner cases where the read and write pointers are very close, it may
not be possible to read out all the wanted samples. This can for example
happen when there is a jump in the graph driver position. Currently, the
code reads the wanted number of samples out of the ring buffer regardless
of the write and read pointer positions. It does so even when the read
pointer is ahead of the write pointer (that is, an underrun occurs).

Fix this by checking the fill level and reading only the available amount
of samples if that amount is less than the wanted amount. The remaining
space in the target buffer is then filled with nullbytes.
2026-02-03 09:07:48 +01:00
Carlos Rafael Giani
a32e6e108c Revert "module-rtp: Remove device_delay from timestamp math"
This reverts commit dcdc19238b.

Reverting this because it caused big sync errors of ~62 ms in test setups.
Further discussions about this can be found here:

https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/2666

Followup commits modify the device delay application (by scaling it),
which is another reason why this needs to be reverted.
2026-02-03 09:07:36 +01:00
Barnabás Pőcze
cad1df748e meson.build: define SPA_AUDIO_MAX_CHANNELS for C++ as well
Previously the override was only present in `cc_flags`, meaning that
C++ source files, like `aec-webrtc.cpp`, would not have it.

Fixes: 6d74eee874 ("spa: bump channels to 128 again")
2026-02-02 18:13:14 +01:00
Wim Taymans
3c80f0fb3e filter-graph: add gain option to sofa
So that we can apply the gain to the IR. This is more efficient than
doing a volume after the convolution.

See #5098
2026-02-02 16:28:54 +01:00
Pauli Virtanen
f60e03b4ef pulse-server: use timeout also for creating sample-play streams
Add 35 sec timeout for PLAY_SAMPLE streams to start streaming, similar
to what we do with normal streams, and fail playback if they don't
start.

This avoids pending sample playback using up resources indefinitely if
streams fail to start for some reason, e.g. session manager is not
linking them.
2026-02-02 11:25:01 +00:00
Pauli Virtanen
a50e9a995e pulse-server: disconnect from server on EPROTO
If we get EPROTO, we likely have missed on some messages from the
server, and our state is now out of sync.

It's likely we can't recover (e.g. if error is due to fd limit hit), so
just drop the server connection in this case, similarly as if we got
EPIPE.
2026-02-02 11:16:15 +00:00
Alexander Sarmanow
f34a87fe38 bluez5: bap: add support for per adapter broadcast config
By setting the hci handle (e.g. hci0) of the desired adapter, the BIG
config will only applied on that adapter. In case no "adapter" entry in
the config is given, it will be applied on all adapters.

Signed-off-by: Alexander Sarmanow <a.sarmanow@televic.com>
2026-02-02 11:15:41 +00:00
Frédéric Danis
1a478c7147 bluez5: Fix stack smashing crash in remote_endpoint_update_props()
Commit 2942bae034 introduced parsing of
"SupportedFeatures" which uses a third DBusMessageIter pointer.

*** stack smashing detected ***: terminated
==389050==
==389050== Process terminating with default action of signal 6 (SIGABRT)
==389050==    at 0x4F57B2C: __pthread_kill_implementation (pthread_kill.c:44)
==389050==    by 0x4F57B2C: __pthread_kill_internal (pthread_kill.c:78)
==389050==    by 0x4F57B2C: pthread_kill@@GLIBC_2.34 (pthread_kill.c:89)
==389050==    by 0x4EFE27D: raise (raise.c:26)
==389050==    by 0x4EE18FE: abort (abort.c:79)
==389050==    by 0x4EE27B5: __libc_message_impl.cold (libc_fatal.c:134)
==389050==    by 0x4FEFC48: __fortify_fail (fortify_fail.c:24)
==389050==    by 0x4FF0ED3: __stack_chk_fail (stack_chk_fail.c:24)
==389050==    by 0xBC1D1A1: remote_endpoint_update_props (bluez5-dbus.c:3137)
==389050==    by 0xB53609F: ???
==389050==    by 0x1DF: ???
==389050==    by 0x61C17BF: ??? (in /usr/lib/x86_64-linux-gnu/libdbus-1.so.3.32.4)
==389050==    by 0x1DF: ???
==389050==    by 0xC5ED113: ???
2026-01-30 18:02:38 +01:00
Wim Taymans
69d8822303 filter-chain: tweak spatializer gain
We're adding two signals together so half the gain to keep it at
the same volume.
2026-01-29 16:52:02 +01:00
Wim Taymans
47dd57faa7 filter-graph: handle other SOFA errors as errno 2026-01-29 16:50:52 +01:00
Wim Taymans
2aecb49f50 pulse-server: use null to clear the value
The message makes it seem that you can pass 'clear' to clear the setting
but in fact you should pass 'null'.
2026-01-27 10:17:34 +01:00
Arun Raghavan
ed59342d28 pipewire-pulse: Expose bluetooth headset autoswitch config as a message
Makes it easier for libpulse-based clients to modify this setting if
they want.
2026-01-26 14:44:30 -08:00
Arun Raghavan
703380d62d pulse-server: Fix querying after setting of mono mixdown 2026-01-26 14:37:08 -08:00
Mengshi Wu
bc53b6b343 bluez5: Remove unused bt_features variable in sco_create_socket. 2026-01-25 17:26:15 +00:00
Mengshi Wu
332e35039d doc: Fix bluez5.hw-offload-datapath property type in documentation 2026-01-25 17:26:15 +00:00
Mengshi Wu
254620676f bluez5: Use named constants for Bluetooth codec IDs
Replace magic numbers (0x02, 0x05) with named constants BT_CODEC_CVSD
and BT_CODEC_MSBC for better code readability. Also remove redundant
zero initialization of num_caps field since the buffer is already
memset to zero.
2026-01-25 17:26:15 +00:00
Mengshi Wu
78f16bc04b bluez5: Remove hw-offload feature flag check and associated quirks
The sco_offload_btcodec() function now returns void and only skips
offload setup when using the default datapath, simplifying the logic
and removing the need for explicit feature flag checks.
2026-01-25 17:26:15 +00:00
Mengshi Wu
2b5d21da5b bluez5: simplify SCO datapath parsing with spa_atou32 2026-01-25 17:26:15 +00:00
Mengshi Wu
2d6a7d2186 bluez5: fix format string in sco_offload_btcodec log message 2026-01-25 17:26:15 +00:00
Mengshi Wu
db7c74a042 bluez5/backend-native: Add HFP/HSP hardware offload datapath configuration
Add support for configuring the SCO hardware offload data path for
HFP/HSP profiles using the Bluetooth SIG-specified procedure. This
enables vendor-specific SCO offload integrations.

Changes:
- Add `bluez5.hw-offload-datapath` configuration property (default: 0)
- Implement `sco_offload_btcodec()` to set BT_CODEC socket option
- Add `SPA_BT_FEATURE_HW_OFFLOAD` quirk feature flag
- Apply offload configuration when creating SCO sockets if quirk enabled
- Document new property in pipewire-props.7.md

The datapath ID is configurable via device parameters and only applied
when the hardware offload feature flag is set in quirks, allowing
platform-specific SCO offload implementations.
2026-01-25 17:26:15 +00:00
Wim Taymans
35817c0d85 pw-cat: support some more formats
So that you can give an .oga extension and --format=opus to get an
opus ogg file.
2026-01-22 17:14:41 +01:00