Commit graph

5558 commits

Author SHA1 Message Date
Wim Taymans
a0518e28bb audioconvert: avoid some float/double/int conversions 2026-04-22 18:00:59 +02:00
Wim Taymans
9c9a5ac435 convolver: returned processed samples 2026-04-22 16:13:56 +02:00
Wim Taymans
495c1c9dd0 dsp: precalculate the scale 2026-04-22 16:13:56 +02:00
Wim Taymans
3c2552e671 dsp: add SSE and AVX2 mult and linear functions 2026-04-22 16:13:56 +02:00
Wim Taymans
3e7e61dcb7 convolver: small cleanups
Remove unused field.
We can also remove the ifft and reuse the fft.
2026-04-22 16:13:56 +02:00
Wim Taymans
aabcbf1261 dsp: move scaling out of complex multiply
do scaling as part of iFFT.
2026-04-22 16:13:56 +02:00
Wim Taymans
7fc020098c dsp: shuffle per implementation 2026-04-22 16:13:56 +02:00
Wim Taymans
46b8380490 dsp: store Real/Imag in blocks of 8
Shuffle FFT output into real/imag blocks so that they are easier to
handle in the complex multiply. Do the unshuffle again before doing the
inverse FFT.
2026-04-22 16:12:20 +02:00
Wang Yu
2953f48d9b vulkan: fix wrong descriptor image info index
When streams are skipped via continue in updateDescriptors(),
the loop index i and descriptorSetLen diverge. The image info
is written at descriptorSetLen but pImageInfo was referencing
index i, pointing to uninitialized memory and causing incorrect
Vulkan descriptor updates.

Fix by using descriptorSetLen consistently.

Signed-off-by: Wang Yu <wangyu@uniontech.com>
2026-04-21 15:13:03 +00:00
Wim Taymans
c6ae30593c filter-graph: use convolver2 for sofa
We don't need 2 convolvers anymore, we can use the same convolver with
2 outputs with the left and right ir.

Add latency option to the sofa plugin. I believe the latency of the
SOFA filters is by default 0, so use that.
2026-04-21 16:52:49 +02:00
Wim Taymans
9cae4ce7e7 filter-chain: add convolver2
Add support for multiple convolver outputs. This makes things more
efficient because we only need to do the input FFT once to produce the N
outputs.

Add convolver2 that can have multiple outputs.
2026-04-21 16:24:38 +02:00
Wim Taymans
2b96f694f7 convolver: rename some fields 2026-04-20 14:00:15 +02:00
Wim Taymans
d8db536d36 convolver: remove some useless loops 2026-04-20 14:00:04 +02:00
Wim Taymans
777851a7ec convolver: support more than 2 partitions
Currently wired up to only support 2 but it can be changed.
2026-04-20 13:59:08 +02:00
Wim Taymans
b9e62aad8a convolver: handle partial blocks 2026-04-20 13:57:47 +02:00
zuozhiwei
2722d16303 audioadapter: remap port id for port_reuse_buffer on target
port_use_buffers and related port methods increment port_id when the
implicit output direction differs from the adapter's primary direction.
port_reuse_buffer only receives a port id but applies to output ports,
so apply the same offset before forwarding to this->target.

Also update videoadapter for the same mapping.
2026-04-20 07:55:54 +00:00
zuozhiwei
c3d16a39f5 audioconvert: fix tmp_datas[1] when scratch ports grow 2026-04-20 10:24:42 +08:00
Pauli Virtanen
cee1bdfb5a bluez5: more MT7925 quirks
The MT7925 chipset has several alternative USB ids recognized by kernel,
list them all.
2026-04-19 16:02:56 +00:00
Pauli Virtanen
84e6845aa6 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.
2026-04-17 22:10:32 +00:00
Pauli Virtanen
6e8e234e61 bluez5: fix disabling HFP codecs via bluez5.codecs
backend-native should not advertise disabled HFP codecs as available.
2026-04-17 19:35:43 +03:00
Wim Taymans
5f9811d085 convolver: clear the input buffer
The last part of the buffer needs to be 0 filled or else we get noise
from the FFT.
2026-04-17 12:47:32 +02:00
Wim Taymans
f210d93ea6 convolver: remove intermediate convolver
We can simply use the first one with more segments.
2026-04-17 10:39:36 +02:00
Wim Taymans
839e0a4aaf convolver: optimize loops
We can use a single loop with just one memcpy to implement the delay
buffer and feed the different FFTs.
2026-04-17 10:38:38 +02:00
Wim Taymans
37b648a3e0 convolver: convolver1 -> partition 2026-04-17 10:37:13 +02:00
Masum Reza
f76327e076 alsa: acp: don’t override user-selected port on availability changes
ACP was re-selecting the “best” port on every port availability event,
even when a port was already explicitly selected by the user. This
differs from PulseAudio’s behavior, where port switching decisions are
left to higher-level policy.

This caused issues on devices where Line Out (speakers) and Headphones
share the same analog interface: when headphones are plugged in, ACP
would immediately switch away from the user-selected Line Out, or end up
in a state where no sound is produced despite selecting speakers explicitly from
clients like pwvucontrol.

Fix this by only re-evaluating and switching ports when:
  - no active port is currently selected, or
  - the active port has become unavailable

This preserves manual user choices and prevents ACP from fighting client
port selections during route activation.

Additionally, adjust ALSA mixer paths to better separate Line Out and
Headphones behavior:
  - Disable Line Out controls in the headphones path
  - Add explicit Line Out and Auto-Mute Mode handling in the lineout path

Together, these changes align PipeWire’s behavior more closely with
PulseAudio and fix cases where selecting speakers while headphones are
plugged results in no audio output.

Signed-off-by: John Titor <masumrezarock100@gmail.com>
2026-04-16 10:45:01 +00:00
Wim Taymans
adad89dc0e add spa_memcpy to more places
Use spa_memcpy yo where we memcpy data so that when the debug option is
enabled we can see more.
2026-04-16 12:16:06 +02:00
Wim Taymans
35cbd2e56a audioconvert: don't setup again in suspend
Remove the fallthrough in suspend, we don't want to do the setup that we
do in the paused mode, just reset the node and unset the started state.
2026-04-16 10:12:09 +02:00
Wim Taymans
03fd89abea 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-15 11:20:18 +02:00
zuozhiwei
3277f3acfb 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-15 09:17:49 +00:00
Wim Taymans
ae723a69f6 filter-graph: allow negative Gain in mixer
To allow for polarity changes.

Fixes #5228
2026-04-15 09:41:55 +02:00
Wim Taymans
823dcd8843 scheduler: make nodes move to IDLE when inactive
When a node is inactive but linked to a driver, the only reason it is
not being scheduled is because it is inactive.

We already set up the links and negotiate the format and buffers to
prepare going to RUNNING. This patch now also make the node go to IDLE,
which makes the adapter negotiate a forma and buffers with the internal
node.

This makes things more symetrical, when linking a node, it becomes IDLE,
when activating it becomes RUNNABLE, when inactive it goes back to IDLE.
The switch to RUNNING will also be faster when things are already set up
in the IDLE state.

The main advantage is that it allows us to implement the startup of
corked streams in pulseaudio better. Before this patch we had to set the
stream to active to make it go through the Format and buffer negotiation
and then quickly set it back to inactive, hopefully without skipping a
cycle. After this patch, the corked stream goes all the way to IDLE,
where it then waits to become active.

See #4991
2026-04-14 14:28:29 +02:00
Wim Taymans
474253719f 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-14 11:09:29 +02:00
Wim Taymans
0cc3644e55 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-13 10:26:33 +02:00
zuozhiwei
11d28c661b Fix spelling errors in comments and log messages
- Fix durring → during in es-builder.c error message
- Fix capabilty → capability in impl-port.c debug log
- Fix supress → suppress in rate-control.h comment

Improve code readability
2026-04-13 07:20:11 +00:00
Wim Taymans
5075f27ea0 filter-graph: small convolver optimizations
Use FMA when we can, make sure FMA compilation is supported and the CPU
also supports it at runtime.

Avoid divisions by doing the modulo increment more explicitly.
2026-04-10 12:17:25 +02:00
Martin Geier
42415eadd9 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.
2026-04-09 08:00:37 +00:00
Wim Taymans
dc47f9ea45 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:45:28 +02:00
Wim Taymans
7012594926 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 12:00:04 +02:00
Wim Taymans
50aacea749 plugins: allow some absolute paths
Allow abosulte paths as long as they start with one of the search paths.
2026-04-07 09:44:22 +02:00
Wim Taymans
57299da899 filter-graph: improve debug when loading fails
List the path name and the plugin search path when we can't load an
error.
2026-04-06 15:01:43 +02:00
Wim Taymans
8fd7982087 only dlopen from the defined search paths
Don't accept absolute library paths and skip the ../ in paths to avoid
opening arbitrary libraries from unexpected places.
2026-04-06 14:20:56 +02:00
Pauli Virtanen
ad0bab69a1 spa: system: make spa_poll_event compatible with epoll_events
spa_poll_event should have exactly same layout as epoll_events to be
compatible across platforms. The structure is packed only on x86-64.

Fix packing and replace the data member with similar union as
epoll_data, to fix compatibility on 32-bit etc.
2026-04-06 10:24:32 +00:00
Alexander Sarmanow
54a4515b09 bluez5: bap: add support for manual BIS config 2026-04-05 20:18:22 +00:00
ValdikSS
ee1b429441 bluez5: aac: Use VBR encoding with Mode 5 by default 2026-04-05 20:24:47 +03:00
ValdikSS
a35b6b0c4b 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)
2026-04-05 20:24:47 +03:00
ValdikSS
49d5f4f236 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
2026-04-05 20:24:47 +03:00
Wim Taymans
67dd3549a7 system: use attribute packed for the spa_poll_event
This makes it the same size as epoll_event and we don't need to copy the
results over.

It however technically causes an ABI break, in case someone was using
the system interface directly.
2026-04-01 16:28:47 +02:00
Carlos Rafael Giani
9ba92bd728 spa: Do not perform upper range check on 32-bit platforms 2026-03-30 23:31:36 +02:00
Wim Taymans
18c97222c4 channelmix: make up/downmix levels configurable
Add channelmix.center-level, channelmix.surround-level and
channelmix.lfe-level to control how center, surround and LFE is
up/downmixed.

Fixes #5198
2026-03-30 17:50:48 +02:00
Sriman Achanta
03f894bab0 alsa-udev: Add wireless device status monitoring 2026-03-30 07:43:27 +00:00