Commit graph

5305 commits

Author SHA1 Message Date
Wim Taymans
0c33101a42 pod: remove unused function 2025-07-24 18:22:14 +02:00
Wim Taymans
a85c24e9ca builder: support building pod + data + suffix
Add a function that can build a pod from a pod definition, a body data
and a suffix.

We can use this to build strings and bytes and arrays like the other
primitives, which makes it possible to add them to choices or arrays.

Fixes #4588
2025-07-24 16:23:54 +02:00
Demi Marie Obenour
a09bf57944 meson: Always use -fno-strict-aliasing and -fno-strict-overflow
SPA does not respect the C strict aliasing rules at all, so any code
that uses it must be built with -fno-strict-aliasing.  Furthermore,
there is code in SPA that compares pointers that point to different
objects, so -fno-strict-overflow is also needed.
2025-07-24 07:30:28 +00:00
Barnabás Pőcze
c7838cbbcb spa: node: io: fix typo in documentation
`SPA_IO_RATE_MATCH_ACTIVE` -> `SPA_IO_RATE_MATCH_FLAG_ACTIVE`
2025-07-23 21:26:29 +02:00
Pauli Virtanen
5fa137cc0d meson.build: make spa-json-dump available for subprojects
Add override that provides host binary for subprojects to use.

Also fix cross-compilation to use the host binary.
2025-07-23 12:19:21 +00:00
Wim Taymans
0b0912cc5b resample: optimize phase scaling
Precalculate the constant factor to avoid a division for each sample.
2025-07-23 14:11:11 +02:00
Wim Taymans
b52c490709 resample: fix compilation
Also fix a compiler warning in clang
2025-07-23 12:52:27 +02:00
Wim Taymans
d2a9141913 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 12:23:20 +02:00
Wim Taymans
fcc49ad517 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 11:55:49 +02:00
Wim Taymans
685aed1de2 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-22 16:48:43 +02:00
Niklas Carlsson
fc3a199ca2 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:44:08 +02:00
Wim Taymans
5b436abef7 pod: improve compare function
Use the area to compare two rectangles. Use the width to break a tie.

This way the sorting is at least a bit more predictable and independent
of the order of the arguments.
2025-07-22 14:19:08 +02:00
Wim Taymans
495d6ba796 pod: remove some size checks
These are already done by the caller.
2025-07-22 14:09:10 +02:00
Wim Taymans
e91c541446 pod: disable padding when in body
Disable the padding to pod alignment for everything when we are building
the body of an array or choice.

This makes it possible to use bytes or strings or any other pod of a
fixed size as entries in arrays or choice.
2025-07-22 13:58:11 +02:00
Wim Taymans
b904cb14a9 pod: do size check before calling type/size/data functions
Assume that all the functions that take a type/size/data from a pod have
at least the right number of bytes in the data for the given type.
Callers need to ensure this.

Fix the callers of such functions to always make sure they deref a pod
type/size/body into something of at least the min size of the type.
2025-07-22 13:14:17 +02:00
Wim Taymans
0a52f959ac pod: add a function to return the min size of a type 2025-07-22 13:13:05 +02:00
Wim Taymans
a03bbc79fe pod: fix compilation 2025-07-22 12:20:05 +02:00
Demi Marie Obenour
05bd4547d0 pod: parser: avoid unneeded integer division
SPA_POD_CHOICE_N_VALUES involves an integer division, which is slow.
Replace it with subtraction and comparison.

No functional change intended.
2025-07-22 10:19:33 +00:00
Wim Taymans
da1d4fb30c pod: also check choice size before cast
Do a more thorough test of the choice type by not only checking the type
but also if the size is at least large enough to be able to cast it to
the pod_choice type and look at the contents.
2025-07-22 12:14:06 +02:00
Wim Taymans
ed7398a64a pod: use _deref and _frame in safe place
In the filter, don't _deref or use _frame before we are going to add
more pods to the builder. If we are using a dynamic builder, the
dereffed pod might become invalid when the memory is reallocated.

Instead, take the offset of the frame and deref later when we are not
going to add more things.
2025-07-22 10:06:07 +02:00
Wim Taymans
ff7fb675f1 pod: avoid overflow in _frame() 2025-07-22 09:43:50 +02:00
Karl Relton
9189b1d8b7 Add ACP for Logitech 407 USB PC Speaker set 2025-07-21 12:25:26 +00:00
Karl Relton
eac495f0e7 Option of analog or iec958 stereo output, both merging volume switches 2025-07-21 12:19:13 +00:00
Karl Relton
47e8984450 Upload New File 2025-07-21 12:17:40 +00:00
Wim Taymans
36f288f884 pod: require at least 1 choice value in _can_collect()
We can't collect the choice value when there is none so check for the
number of choice values in _can_collect() as well.
2025-07-21 10:14:39 +02:00
Wim Taymans
f2fb0b0aa5 alsa: update resample state in all cases
We need to manually recheck the resample state when the matching state
got updated.
2025-07-18 19:20:00 +02:00
Wim Taymans
5fba59b41d mixer-dsp: fix compilation with fastpath debug 2025-07-18 19:19:34 +02:00
Wim Taymans
ce2989891d alsa: init the bw_max value
Otherwise, rate matching doesn't work when it's left to 0.0.
2025-07-18 18:21:18 +02:00
Wim Taymans
5cd7b1de16 mixer-dsp: rework the port management
Keep a list of active ports in the port_list. These are all ports added
with add_port and not yet removed. When a port is removed, move it to
the free_list and reuse the port later when needed.

Update a mix_list of ports when a valid io is set on a port. This then
makes it possible to more efficiently and safely iterate the ports in
the processing loop.
2025-07-18 16:43:22 +02:00
Wim Taymans
ec5d2d2a29 audioconvert: rework the stage recalc a little
Use bits to capture the work that is needed. We clear the bit when
we added the stage, when all bits are cleared we have nothing more to
do. This avoids having to check multiple bookleans.

Make a helper function to calculate the destination buffer. When all
bits are cleared, we can use the output buffer.
2025-07-18 12:10:30 +02:00
Wim Taymans
8babd0bc4e audioconvert: remove unused field 2025-07-18 12:02:28 +02:00
Carlos Rafael Giani
c504851dca alsa-compress-offload-sink: Improve write_queued_output_buffers comments 2025-07-18 10:53:59 +02:00
Carlos Rafael Giani
48716a72b1 alsa-compress-offload-sink: Remove unused variable 2025-07-18 10:53:52 +02:00
Carlos Rafael Giani
14b242c737 node-driver: Make sure the discont clock flag does not remain set forever
If the timer was canceled, the discont flag needs to be set. But in the
next cycle, unless the timer was canceled again, that flag should not
remain set.
2025-07-18 10:52:13 +02:00
Carlos Rafael Giani
bb022c1b84 node-driver: Handle realtime clock modifications
If the user alters the realtime clock (for example by using the "date"
command in the shell), and the node driver uses the realtime clock as
the timerfd clock, then the scheduled graph cycle invocation may not
take place, or may take place much later than planned, because the
timestamp that was passed to spa_system_timerfd_settime() is now invalid.
Configure the timer to automatically be canceled if the realtime clock
is modified so that the graph cycle can be rescheduled with an updated
timestamp that is actually usable with the altered realtime clock.
2025-07-17 13:13:34 +00:00
Wim Taymans
ece2890c8b meson: remove avutils as a ONNX dependency 2025-07-17 14:08:20 +02:00
Wim Taymans
efa4d31cfb meson: use libonnxruntime so that the .pc file can be found 2025-07-17 14:02:19 +02:00
Wim Taymans
6605caa39e filter-graph: add ONNX plugin
It uses the onnxruntime library to parse the onnx file and construct a
neural network. It uses the label field to setup the plugin and how to
map the various tensors of the model to input, output, control and
notify ports.

Add an example config for how to use the silero VAD ONNX model with the
noise gate.
2025-07-17 13:16:00 +02:00
Wim Taymans
b3dddfed6a filter-chain: add Level control input port for noisegate
This makes it possible to use another volume measurement algorithm to
drive the noise gate, such as a VAD algorithm.
2025-07-17 12:12:24 +02:00
Wim Taymans
4b37f3db3d filter-graph: move loop out of the NULL check 2025-07-17 12:12:22 +02:00
Carlos Rafael Giani
eb3d14053d doc: spa: Add more docs about SPA_IO_Clock and driver operations 2025-07-16 10:58:48 +02:00
Carlos Rafael Giani
67711e899c audioadapter: Add more log lines 2025-07-16 10:58:48 +02:00
Wim Taymans
328e101f37 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-15 15:06:24 +02:00
Wim Taymans
0be61add02 Revert "spa: alsa: Try to get driver rate before setting up matching"
This reverts commit 019b53ace8.

This is a result of a different problem, that the rates are compared
when they are unset.
2025-07-15 14:52:31 +02:00
Wim Taymans
da9bd36cbb spa: return before entering the error branch
In the normal case we should not go into the error path.
2025-07-15 14:51:24 +02:00
Demi Marie Obenour
b04da87e38 pod: check that choices are not empty
Before using the contents of a choice, check that it is not empty to
avoid reading out of bounds.
2025-07-15 10:13:18 +02:00
Demi Marie Obenour
d37bdf5cbf pod: check for NULL strings in tag utils
SPA_POD_String allows SPA_TYPE_None PODs and turns them to NULL, so
check for them.
2025-07-15 10:13:18 +02:00
Demi Marie Obenour
edef57f6c3 pod: avoid modulo by 0
a % b is undefined behavior if b is 0.
2025-07-15 10:13:18 +02:00
Demi Marie Obenour
fb315b9050 *: Missing bounds checks in POD handling
There were missing bounds checks for ill-formed POD all over the place.
2025-07-15 10:13:17 +02:00
Demi Marie Obenour
7ac94f1a69 pod: ensure strings are NUL-terminated before calling strlen()
SPA_TYPE_String needs to be NUL-terminated, so check that in
spa_pod_compare_value().
2025-07-15 10:13:17 +02:00