Commit graph

4578 commits

Author SHA1 Message Date
Pauli Virtanen
04af44d5c3 bluez5: more MT7925 quirks
The MT7925 chipset has several alternative USB ids recognized by kernel,
list them all.

(cherry picked from commit cee1bdfb5a)
2026-04-19 19:15:23 +03:00
Pauli Virtanen
bb6199214d bluez5: add quirk for LC3-24kHz for HFP
MT7925 fails to setup a SCO connection that results to working LC3-24kHz
audio. Other controllers (Intel etc) appear to work OK.

Add quirk for disabling this codec, and disable it for this Mediatek
controller.

(cherry picked from commit 84e6845aa6)
2026-04-19 19:15:23 +03:00
Pauli Virtanen
b2028a03f0 bluez5: fix disabling HFP codecs via bluez5.codecs
backend-native should not advertise disabled HFP codecs as available.

(cherry picked from commit 6e8e234e61)
2026-04-19 19:15:23 +03:00
Martin Geier
c148028f5a bluez5: iso-io: don't use streams without tx_latency enabled for fill level calculation
When there is a stream without tx_latency enabled, the fill_count ends
with MIN_FILL value. This causes one buffer of silence to be written to
every stream before the actual data in each iteration.
Consequently, more data is written than consumed in each iteration.
After several iterations, spa_bt_send fails, triggering a
group_latency_check failure in few next iterations and leading to
dropped data.

Skip streams without tx_latency enabled in fill level calculations
to prevent these audio glitches.

(cherry picked from commit 42415eadd9)
2026-04-19 19:15:23 +03:00
Alexander Sarmanow
78888a78c3 bluez5: bap: add support for manual BIS config
(cherry picked from commit 54a4515b09)
2026-04-19 19:15:23 +03:00
ValdikSS
5918e6f05d bluez5: aac: Use VBR encoding with Mode 5 by default
(cherry picked from commit ee1b429441)
2026-04-19 19:15:23 +03:00
ValdikSS
cb1d19e433 bluez5: aac: use higher band limit for CBR mode
FDK-AAC encoder uses band pass filter, which is automatically
applied at all bitrates.
For CBR encoding mode, its values are as follows (for stereo):

* 0-12 kb/s:   5   kHz
* 12-20 kb/s:  6.4 kHz
* 20-28 kb/s:  9.6 kHz
* 40-56 kb/s:  13  kHz
* 56-72 kb/s:  16  kHz
* 72-576 kb/s: 17  kHz

VBR uses the following table (stereo):

* Mode 1: 13   kHz
* Mode 2: 13   kHz
* Mode 3: 15.7 kHz
* Mode 4: 16.5 kHz
* Mode 5: 19.3 kHz

17 kHz for CBR is a limiting value for high bitrate.

Assume >110 kbit/s as a "high bitrate" CBR and increase the
band pass cutout up to 19.3 kHz (as in mode 5 VBR).

Link: d8e6b1a3aa/libAACenc/src/bandwidth.cpp (L114-L160)
(cherry picked from commit a35b6b0c4b)
2026-04-19 19:15:23 +03:00
ValdikSS
cc71d011e0 bluez5: aac: use maximum possible peak bitrate according to MTU
Android 11 and newer, in both CBR and VBR modes,
* Sets bitrate (AACENC_BITRATE) to the max_bitrate value of A2DP
* Sets peak bitrate (AACENC_PEAK_BITRATE) according to the maximum data
   which could fit into single audio packet based on MTU

AACENC_BITRATE is used only in CBR mode. For VBR mode, the only limiting
factor is AACENC_PEAK_BITRATE.

Do the same in Pipewire.

Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/work_items/1482#note_2949680
Link: https://cs.android.com/android/platform/superproject/+/android16-qpr2-release:packages/modules/Bluetooth/system/stack/a2dp/a2dp_aac_encoder.cc;drc=37d7b4549f7b8740df1a290f04c20c591a2d3391;l=269
(cherry picked from commit 49d5f4f236)
2026-04-19 19:15:23 +03:00
Wim Taymans
e0697f52c3 alsa-seq: add : between client and port name
The separator is important for applications to find the client name and
group ports.

Fixes #5229
2026-04-16 10:19:05 +02:00
zuozhiwei
b0f719edd4 alsa: fix inverted port validity check in port_reuse_buffer
The CHECK_PORT condition in impl_node_port_reuse_buffer was inverted with a negation operator, causing the function to reject valid output ports and accept invalid ones.

Fixes the logic so that valid ports proceed to buffer recycling and invalid ports are properly rejected.
2026-04-16 10:18:58 +02:00
Wim Taymans
db0fa4b419 filter-graph: allow negative Gain in mixer
To allow for polarity changes.

Fixes #5228
2026-04-16 10:18:47 +02:00
Wim Taymans
d9b6153123 alsa-seq: remove port from mix_list on destroy
When the port is destroyed we need to remove it from the mix_list or
else the process function will keep trying to use the invalid memory.

This is because the port logic does not want to call any functions on
the port (like clearing the IO or Format) after it emitted the destroy
signal and we need to clean up ourselves.

Fixes #5221
2026-04-16 10:18:30 +02:00
Wim Taymans
8be0d7534b dlopen: support search path ending in /
When the search path is /usr/lib/, /usr/lib/foo.so fails to load because
there is no / after the search path. Fix this by requiring that either
the search path end with / or the following char is a /.
2026-04-16 10:18:03 +02:00
Wim Taymans
d6adf944df filter-graph: return current control value correctly
The control values are only set in the port control_data after the
filter has been activated and the instances are created.

Property enumerations might happen before that and then we can either
return the current_value (when set in a control section or later with a
param property) or the default value.
2026-04-08 17:55:33 +02:00
Wim Taymans
821b62dac5 dlopen: improve prefix check some more
If we pass a path /usr/libevil/mycode.so, it might have a prefix of
/usr/lib but we should still reject it. Do thi by checking that after
the prefix match, we start a new directory.
2026-04-08 16:22:04 +02:00
Wim Taymans
fd867cf655 mixer: handle control.ump property
Add a control.ump port property. When true, the port wants UMP and the
mixer will convert to it. When false, the port supports both UMP and
Midi1 and no conversions will happen. When unset, the mixer will always
convert UMP to midi1.

Remove the CONTROL_types property from the filter. This causes problems
because this is the format negotiated with peers, which might not
support the types but can still be linked because the mixer will
convert.

The control.ump port property is supposed to be a temporary fix until we
can negotiate the mixer ports properly with the CONTROL_types.

Remove UMP handling from bluetooth midi, just use the raw Midi1 events
now that the mixer will give those and we are supposed to output our
unconverted format.

Fix midi events in-place in netjack because we can.

Update docs and pw-mididump to note that we are back to midi1 as the
default format.

With this, most of the midi<->UMP conversion should be gone again and we
should be able to avoid conversion problems in ALSA and PipeWire.

Fixes #5183
2026-04-07 10:08:14 +02:00
Wim Taymans
6a8bf93768 midi: don't convert Midi in nodes
Avoid doing conversions in the nodes between Midi formats, just assume
the imput is what we expect and output what we naturally produce.

For ALSA this means we produce and consume Midi1 or Midi2 depending on the
configurtation.

All of the other modules (ffado, RTP, netjack and VBAN) really only
produce and consume MIDI1.

Set the default MIDI format to MIDI1 in ALSA.

Whith this change, almost everything now produces and consumes MIDI1
again (previously the buffer format was forced to MIDI2).

The problem is that MIDI2 to and from MIDI1 conversion has problems in
some cases in PipeWire and ALSA and breaks compatibility with some
hardware.

The idea is to let elements produce their prefered format and that the
control mixer also negotiates and converts to the node prefered format.
There is then a mix of MIDI2 and MIDI1 on ports but with the control
port adapting, this should not be a problem.

There is one remaining problem to make this work, the port format is
taken from the node port and not the mixer port, which would then expose
the prefered format on the port and force negotiation to it with the
peer instead of in the mixer.

See #5183
2026-04-07 10:07:00 +02:00
Wim Taymans
a0c3c2d9e4 mixer: only add input ports to mixer 2026-04-07 10:05:20 +02:00
Wim Taymans
6bc07dfe0e only dlopen from the defined search paths
Don't accept absolute library paths that are not in the search path,
skip the ../ in paths to avoid opening arbitrary libraries from
unexpected places.
2026-04-07 09:51:47 +02:00
George Kiagiadakis
dcb86450c8 bluez5: parse the broadcast adapter value from the correct iterator
(cherry picked from commit 0d1280a5b2)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
35e3608d0e bluez5: media-source: don't crash if BAP streams doesn't have iso_io
Don't crash in update_target_latency() if a BAP stream doesn't have
iso_io for some reason.

(cherry picked from commit 3dff64364f)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
fb4567232d bluez5: cleanup get_codec_profile()
Check codec kinds for each direction properly when mapping to profiles
corresponding to it. Being sloppy here masked another bug, so best fix
it.

(cherry picked from commit 22a5fad902)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
99f901de06 bluez5: fix spa_bt_device_supports_media_codec() for HFP codecs
HFP codecs don't have a direction dependent "target" profile, and this
function was returning false if A2DP is disabled.

Don't check target profile for HFP, leave checks to backend.

Fixes HFP-only configurations, which were missing profiles.

(cherry picked from commit 75c3d3ecf8)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
929be3252f bluez5: sbc: clean up codec_enum_config
Non-spec compliant devices may set multiple bits in code config, which
we currently reject in validate_config().

enum_config() does work to deal with multiple bits set, but this is
never used, so write the code in a simpler way to return a single
configuration.

(cherry picked from commit d42646e91f)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
535d2f159e bluez5: aac: for multiple bits in aot, normalize to mandatory
Non-spec compliant devices may set multiple bits in AAC AOT, which is
invalid.

In this case, we should normalize to MPEG-2 AAC LC which is the
mandatory value in spec, not to MPEG-4 AAC LC. In select_config() we
also prefer MPEG-2 over MPEG-4.

(cherry picked from commit 67b4732c26)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
97865f8550 bluez5: aac: coerce non-spec compliant freq/channels to single choice
Some non-spec compliant devices (Sony XB100) set multiple bits
in all AAC field, including the frequency & channels.

Although they set multiple bits, these devices appear to intend that the
sender picks some specific format and uses it, and don't work correctly
with the others.

validate_config() already picks one configuration, so use the result in
enum_config(), instead of allowing also other settings.

Assume devices generally want preferably 44.1 kHz stereo.

Note we cannot reject the configuration, as BlueZ does not necessarily
retry, leaving the device connected but with no audio.

(cherry picked from commit 5f8ece7017)
2026-03-30 07:44:33 +00:00
Pauli Virtanen
6b2a207fd9 bluez5: backend-native: don't crash without dbus session bus
When there is no DBus session bus, creation of the telephony backend
fails, and we later crash on null ptr deref.

In this case, avoid crash trying to create telephony_ag or iterate its
call list.

(cherry picked from commit f9e2b1d8b9)
2026-03-30 07:44:33 +00:00
Frédéric Danis
93dfae0ddf bluez5: bap: Fix typos
(cherry picked from commit ee18160c4e)
2026-03-30 07:44:33 +00:00
Barnabás Pőcze
27eedc0396 spa: libcamera: use std::span
libcamera is planning to move to C++20 and drop the custom `libcamera::Span`
type at some point in the future. Since pipewire already uses C++20, remove
all uses of it and instead use `std::span` so that things will compile
after the removal.

(cherry picked from commit 84e7b744a6)
2026-03-28 01:22:27 +01:00
Wim Taymans
19213d5d48 audioconvert: avoid OOB mix matrix read
Patch by David Nowotny

In make_matrix (channelmix-ops.c), the matrix-filling loop at the done:
label allows the index i (and j in the inner loop) to grow beyond MAX_CHANNELS
when dst_paired/src_paired has sparse bits set. In that case the continue
fires for most values of i < CHANNEL_BITS, so i advances much faster than ic,
and matrix[i][j] reads off the end of the stack-allocated array.

Add bounds guards to both loop conditions so i and j cannot exceed
MAX_CHANNELS.

Fixes #5176
2026-03-17 14:16:10 +01:00
Wim Taymans
fb47e739d9 acp: fix -Werror=discarded-qualifiers error 2026-03-16 13:11:20 +01:00
Wim Taymans
54d0d4e55a filter-graph: fix up def/min/max values for lv2
lv2 filters can return NAN for the min/max and default values when not
specified. Handle them so that we don't end up clamping NAN numbers.

Fixes #5166
2026-03-16 12:32:46 +01:00
Wim Taymans
31874b3764 filter-graph: only use min/max when defined in LADSPA
Fixes #5170
2026-03-16 12:32:42 +01:00
Wim Taymans
f4a6648aa5 filter-graph: emit control change after loading
Always do a control change to the instances when they are created. This
is to make sure the internal state is synced to the control values.

The sofa filter and biquads need this to correctly configure themselves
after a suspend.

Fixes #5152
2026-03-11 12:46:17 +01:00
Wim Taymans
cb9b3861ce audiomixer: only add the input port to mix_list
Adding the output port is not a problem because there is never a buffer
to consume and mix but it wastes cycles.
2026-03-11 12:46:12 +01:00
Barnabás Pőcze
17f423b8f6 spa: libcamera: source: SPA_PARAM_Props is write-only
There are no readable `SPA_PARAM_Props` on the node, so mark it write-only.

(cherry picked from commit 810617997b)
2026-03-10 23:50:37 +01:00
Barnabás Pőcze
c3d7373cf9
treewide: fix some -Wdiscarded-qualifiers
Newer glibc versions have made certain `str*()` functions into macros
that ensure that the const-ness of the argument is propagated to the
return type.

(cherry picked from commit e46bfe67b6)
2026-03-10 00:03:14 +00:00
Wim Taymans
299902bd86 v4l2: use 0x as the prefix for hex values
fixes #5161
2026-03-09 16:28:15 +01:00
qaqland
d99a932b9c alsa-udev: support alsa.ignore-dB
Some sound cards are only adapted for Android/macOS and other
systems, without considering Linux. The hardware-reported dB
volume is incorrect (while the percentage volume is normal).
Add support for the ignore-dB option to simplify compatibility.

For example, the 3206:0798 HP SIMGOT GEW1 Sound Card reports:

numid=4,iface=MIXER,name='PCM Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=100,step=0
  : values=100,100
  | dBminmax-min=0.00dB,max=0.39dB

This dB value does not match actual audio perception, and the
vendor attributed this issue to non-target system compatibility.
2026-03-09 16:26:54 +01:00
Wim Taymans
d3946c0b10 node: remove node.link-group from drivers
Sink/Source pairs should not have the same link-group otherwise the
session manager will not be able to autoconnect them with a loopback or
some other internally linked stream.
2026-03-06 11:25:24 +01:00
Barnabás Pőcze
87d1206fb8 spa: libcamera: source: fix stop sequence
Currently it is possible for the request completion handler (`impl::requestComplete`)
to observe `impl::source.fd` while it is being modified in `impl::stop()`.

Fix that by closing the eventfd after the camera has been stopped.

Fixes: 3e28f3e859 ("spa: libcamera: source: rework startup sequence")
(cherry picked from commit 848ac24490)
2026-02-27 11:39:28 +01:00
Damien Espitallier
88cbe24201 alsa-udev: Allow ACTION_REMOVE on ignored cards
Move the card->ignored check to only apply to ACTION_CHANGE, not ACTION_REMOVE. This ensures that ignored cards can still be properly removed when they are unplugged.
2026-02-17 19:19:52 +01:00
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
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
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