Commit graph

5379 commits

Author SHA1 Message Date
Frédéric Danis
e15e50c5ee spa: bluez: backend-native: Prevent HSP/HFP connection in both directions
The HSP and HFP profiles expect that a device function only as an audio
gateway or as an headset, which is the normal behavior for a headset,
a hands-free car unit or a phone.

In case of a desktop, it can perform both functionalities, but there's
no interest to get them at the same time as the bidirectional audio
is already supported.
2025-12-19 07:12:46 +00:00
Frédéric Danis
f468529084 spa: bluez: backend-native: Fix audio connection policy for HSP/HFP 2025-12-19 07:12:46 +00:00
Martin Geier
8c7890eb52 spa: fix missing member initialization
Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2025-12-18 16:53:54 +01:00
Arun Raghavan
e2262617aa spa: alsa: Fix off-by-one check in ELD channel position parsing 2025-12-17 11:08:44 -08:00
Jonas Holmberg
12b2e5d67c audiotestsrc: Operate as follower too
Don't start the timer but fill buffers when following another driver.
2025-12-16 13:15:00 +01:00
Arun Raghavan
ee42b18226 spa: alsa: Guard against mismatched LPCM channel count in ELD parsing
With wonky EDID states, we want to make sure we don't overflow the
available positions.
2025-12-15 12:47:49 -08:00
Frédéric Danis
d89d1668dc spa: bluez: backend-native: Add support for AT+BLDN for PTS tests
This allows to fake Last Dial Number call by calling the first memory.

This allows to pass PTS tests HFP/AG/OCL/BV-01-C and HFP/AG/OCL/BV-02-C.
2025-12-15 08:56:03 +00:00
Frédéric Danis
9a48bbaa36 spa: bluez: modemmanager: Add support for memory dialing for PTS tests
This add a new property to to allow to fake memory dialing for PTS tests
HFP/AG/OCM/BV-01-C and HFP/AG/OCM/BV-02-C.
2025-12-15 08:56:03 +00:00
Mason Remaley
c7ebc66e64 Adds explanation to reduce chance of regressing the fix 2025-12-15 08:20:24 +00:00
Mason Remaley
a6f8e209ac These two functions were marked as static, but referened by the SSE41 implementation in a separate file
I'm not 100% sure if this was breaking SSE41 builds on the official build system (I'm building Pipewire
with a different process), but I suspect it was, because you can't combine these into a single translation
unit to sidestep it without including multiple copies of resample-native-impl.h which isn't desirable.
2025-12-15 08:20:24 +00:00
Wim Taymans
8153efc6ed audioconvert: refactor some code
We sync the filter graph in two places, make a function so that both
places do the same thing.

Make node_reset clear the setup flag so that we don't have to do that
twice.
2025-12-09 21:01:11 +01:00
Torkel Niklasson
40aa6fbb64 audioconvert: Sync filter graphs in setup_convert
If the the audioconvert.filter-chain.N property is set early, they will
be added to the active_graphs list but with setup = false. When the node
starts, setup_convert is called, but the graphs aren't added to
filter_graphs. Run the do_sync_filter_graph at the end of setup_convert
to add them.
2025-12-09 19:52:12 +00:00
Torkel Niklasson
34122b4bf3 audioconvert: Set this->setup to false on flush command
If flush is called, the active graphs are deactivated but this->setup
remains true.
2025-12-09 19:52:12 +00:00
Frédéric Danis
25a6fdcdb1 spa: bluez: device: Add SPA_PROP_params to disable dummy call state
The current implementation only send the +CIEV:<call>,<active> event
if there's an active modem in ModemManager. This may lead to headset
disconnection as in (1) if the profile is by another application than
telephony one, e.g. a conference application/website.

This commit improves dummy call status update by adding a new
"bluez5.disable-dummy-call" props param in bluez5 device, allowing
external application like WirePlumber to set it dynamically.

(1) https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1744

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/2606
2025-12-09 16:08:31 +01:00
Wim Taymans
7aa8d8d628 spa-resample: enable clipping in sndfile
We can actually use a command to enable clipping in sndfile instead
of doing it ourselves.
2025-12-09 13:55:37 +01:00
Wim Taymans
8e6945c496 spa-resample: clamp float values
sndfile does not seem to correctly clip samples so we have to do it
ourselves.
2025-12-09 13:38:46 +01:00
Timon
e1392cec0e Fix disabling of filter chains 2025-12-08 14:19:15 +01:00
Pauli Virtanen
2942bae034 bluez5: parse and enable configuration of TMAP / GMAP features
Parse TMAP / GMAP features from MediaEndpoint:SupportedFeatures and pass
them onto the codec in SelectProperties, so it can determine which
mandatory features the device supports.

Add configuration option for specifying which TMAP / GMAP feature bits
we advertise to remote side.

Although some of these could be determined automatically, for production
systems it's better to have explicit option to specify which ones should
be advertised as this may depend on HW capabilities.
2025-12-06 11:23:48 +00:00
Pauli Virtanen
c623886625 bluez5: fix parsing of 0-element dbus arrays
Type checking by recurse + get_arg_type is wrong for 0-element arrays.
Just check from iterator signature.

Also avoid relying on malloc(0) != NULL
2025-12-06 11:21:56 +00:00
Wim Taymans
a172bf0f55 audiomixer: only passthrough on dynamic data
When the dynamic data flag is set on the buffer data, it means the
consumer can deal with any data pointer set on the buffer and we can
simply pass the one from upstream to downstream. If the flag is not set,
we need to copy the buffer data.

See #5009
2025-12-01 16:33:50 +01:00
Wim Taymans
4f39329ca9 alsa: use graph rate for rate latency
When we recalculate the headroom we also update the latency in frames.
We should express this latency in the graph rate. This is usually the
rate that is suggested in the target_rate but when we are forcing our
own rate (mostly when using IRQ or when in DSD/IEC mode) we should
ignore that value and use our own rate that we will force instead.

Fixes #4977
2025-12-01 14:20:12 +01:00
Wim Taymans
4152c5d292 alsa: add firewire latency before we scale with rate
We first add all the latency in the rate of the pcm device and then
convert it to the rate of the graph.

See #4977
2025-12-01 12:52:37 +01:00
Wim Taymans
2ff45313de resample: allow compilation with custom default quality 2025-12-01 09:52:54 +01:00
Wim Taymans
52ec847cbd filter-graph: add feedback and feedforward to delay
Add feedback and feedforward controls to the delay. This makes it
possible to make comb and allpass filters with the delay to build
custom reverb effects.
2025-11-28 17:10:55 +01:00
Wim Taymans
94c05e9e2d spa: make sure unpositioned raw audio has unknown channels
Otherwise we might end up with partial channels when code doesn't
check the unpositioned flag.  It's better to set everything to unknown
when there is a mismatch between channel count and layout.
2025-11-27 11:45:21 +01:00
Frédéric Danis
6ced56e11d spa: bluez: backend-native: Fix BIEV HF indicators support for HFP AG
The "+BIND: <a>,<state>" reply to AT+BIND? should be sent for every
supported indicator.

"AT+BIEV= <assigned number>,<value>" should only be provided for
enabled indicators. The AG shall respond with an ERROR response code
if it receives updates for disabled or unknown HF indicators or values
that are out of bounds.

This allows to pass PTs tests:
- HFP/AG/HFI/BV-02-C
  AG receives an updated HF Indicator value
- HFP/AG/HFI/BI-03-C
  AG receives invalid updated HF Indicator values
2025-11-25 16:20:02 +01:00
Pauli Virtanen
3b6609f13a bluez5: release transports in CIG/BIG simultaneously
When releasing multiple transports, call Release() simultaneously
instead of serializing the calls.

This operations still needs to be blocking currently, as all releases
have to finish before we do other state-modifying ops.

This works around broken firmware on Creative Zen Hybrid Pro with BAP,
whose Disable command misbehaves when shutting down sink + source CIS
otherwise. It's also anyway better to shut down everything at once.
2025-11-25 09:23:13 +00:00
Wim Taymans
fc26e6321b spa: make cutoff configurable in spa-resample 2025-11-24 16:49:25 +01:00
Wim Taymans
ed2889cecf filter-graph: improve latency reporting of convolver
The latency of the convolver depends on the IR used. It's 0 for /dirac,
len/2 for /hilbert and let's assume it is 0 for file IRs.

Fixes #4980
2025-11-24 13:56:18 +01:00
Wim Taymans
33c7d9cba5 audioconvert: move warn to debug
changing the clock rate is not uncommon and does not need a warning.
2025-11-24 11:03:22 +01:00
Wim Taymans
7d5940101b resample: tweak cutoff some more
Increase the cutoff frequency for the lower quality modes. This should
give significantly better high frequency preservation at the expense of
more (but likely inaudible) aliasing.

Reduce the cutoff for the higher qualities in blackman and exp to
compensate the the wider transition band in those windows.

Increase cutoff for kaiser because of the sharper rolloff.
2025-11-24 10:35:53 +01:00
Wim Taymans
4760fd7f52 resample: tweak kaiser cutoff a little more 2025-11-21 11:42:34 +01:00
Wim Taymans
941fc5f51c spa: add Capability and PeerCapability
Add a new SPA_TYPE_OBJECT_ParamDict object that contains a struct with
key/value pairs. We're using something similar for Tags but this is a
more generic version.

Make a new Capability param that uses the ParamDict object. This is
meant to be used to describe capabilities with the generic key/value
struct.

Make a new PeerParam object where the keys are generic ids of the peer
objects and the values any Pod. The idea is to use this object to store
a peer objects. Make some helpers to iterate the peers and their
objects.

Add a new PeerCapability param that uses the PeerParam object with
Capability objects. This can be used to send the collection of
Capabilities from all peers to a port. This is a bit like the tags but
in a more generic way. The tags could also be implemented in this new
generic way later.

Make the PeerFormats use the same PeerParam of Format objects.

The Capability param is set on ports. impl-link will collect all
Capability objects into a PeerCapability object and send this to the
peer. The difference with the Tag param is that these Capability params
are not in any way forwared on the node automatically (like what is done
in the loopback module) because they represent the capabilities of the
ports betweem the link.
2025-11-21 10:08:46 +01:00
Pauli Virtanen
8d59ad2713 bluez5: set some BAP Context metadata value on streams
Some devices refuse to enable microphone if Streaming Context metadata
is just Unspecified.

Set some reasonable values for the stream context we create along TMAP,
and try follow CAP rules for selecting the PAC.
2025-11-21 08:33:14 +00:00
Pauli Virtanen
2010a525d3 bluez5: simplify ltv parsing 2025-11-21 08:33:14 +00:00
Pauli Virtanen
ff6db3e08e bluez5: add codec_data for codec-private configuration data
With BAP codec configuration selection goes via multiple functions,
which will need to maintain some private state.

Adjust media_codec to allow for that.

Use it for get_qos().
2025-11-21 08:33:14 +00:00
Pauli Virtanen
914e8c6c7a bluez5: parse BAP endpoint Metadata field 2025-11-21 08:33:14 +00:00
Pauli Virtanen
bf801f4f7f bluez5: clean up LTV writing
Add ltv_writer that checks bounds, and use it. Simplify code a bit.
2025-11-21 08:33:14 +00:00
Frédéric Danis
f9f08f7f5c spa: bluez: backend-native: Fix CIEV call status support for HFP AG
Based on HFP specs, the audio connection is independent of the active
call status, which should be managed by the ModemManager part of the
plugin.
But when using HFP AG without modem attached, e.g. during zoom meeting,
the connection will be closed after a while unless call status has been
forced to active,
cf. https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1744.

Currently and for HFP AG PTS tests requesting to get an audio connection
in 3 seconds after a call activates, this prevent to start audio
connection before starting a call.

This commit prevents to force the call status during audio (dis)connection
if a modem is available.
2025-11-21 08:27:44 +00:00
Frédéric Danis
b940d9f3a1 spa: bluez: modemmanager: Fix NameOwnerChanged
Get the ModemManager interfaces when the ModemManager starts after native
HFP has started.

Also add log topic to be able to select log level for modemmanager plugin
part.
2025-11-21 08:26:40 +00:00
Frédéric Danis
5d39e1357e spa: bluez: backend-native: Fix +CNUM reply
PTS test HFP/AG/NUM/BV-01-C expects to receive 5 items, the last one
representing service type which could be 4 for voice or 5 for fax.
2025-11-21 08:22:55 +00:00
Barnabás Pőcze
ae7ac460b9 spa: libcamera: source: ignore frame rate
Do not parse, and do not report the negotiated frame rate. It is
completely ignored. Until support for the `FrameDurationLimits`
libcamera control is implemented, ignore any and all frame rates.
2025-11-21 08:20:30 +00:00
Barnabás Pőcze
ead1c144b2 spa: libcamera: source: remove port::memtype
This field is only used during the setup of buffers, so it can be
transformed into a local variable, but even that is not needed
because the data type can be chosen on a per-plane basis.
2025-11-21 08:20:30 +00:00
Barnabás Pőcze
207421cb7b spa: libcamera: source: remove SPA_VIDEO_FORMAT_UNKNOWN check
It is not used anywhere, so remove it.
2025-11-21 08:20:30 +00:00
Wim Taymans
df075e6628 resample: tweak kaiser resample defaults
Ensure a 110 dB stopband. Set the alpha values accordingly.
2025-11-20 16:55:09 +01:00
Wim Taymans
faf4641625 resample: add some more options to spa-resample
Make it possible to set the params by name. Dump the resampler config
in verbose mode.
2025-11-20 14:07:26 +01:00
Wim Taymans
e8268969ea resample: update params by name
Make the params introspectable, use the names to configure them in
audioconvert.

Only use precomputed filters when using the defaults.

Tweak the kaiser filter alpha and n_taps based on values calculated from
stopband attenuation and transition bandwidth.
2025-11-20 14:07:26 +01:00
Wim Taymans
bfd26c98e3 resample: make window configurable
Add kaiser window
2025-11-20 14:07:14 +01:00
Wim Taymans
18ff08243b spa: add spa_pod_memcmp
Add a helper to memcmp two pods and use it in some places.
2025-11-13 18:13:02 +01:00
Wim Taymans
b9a895f825 adapter: don't recheck formats on driver change
We need to leave this to the converter, like we do for audio.
2025-11-13 18:10:11 +01:00