Commit graph

5286 commits

Author SHA1 Message Date
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
Demi Marie Obenour
5bfc3e6b03 spa: v4l2: avoid integer wraparound to out of bounds read
I'm not sure if untrusted input can reach this point.
2025-07-15 10:13:17 +02:00
Barnabás Pőcze
2c2808fab1 spa: libcamera: manager: fix id allocation
There is an issue in the id allocation mechanism which can result
in the different devices having the same id. Specifically, consider
the scenario where there are only two cameras, which have just been
added. In this case `impl::devices` looks like this:

   (0, camA) | (1, camB) | (?, nullptr) | ...

Now assume that `camA` is removed, after which the array appears
as follows:

  (1, camB) | (1, nullptr) | (?, nullptr) | ...

Then assume that a new camera appears. When `get_free_id()` runs,
when `i == 1`, it will observe that `devices[i].camera == nullptr`,
so it selects `1` as the id. Leading to the following:

  (1, camB) | (1, camC) | (?, nullptr) | ...

This is of course incorrect. The set of ids must be unique. When
wireplumber is faced with this situation it destroys the device
object for `camB` when `camC` is emitted.

Fix this by simply not moving elements in the `devices` array,
leaving everything where it is. In which case the array looks
like this:

  (nullptr) | (camB) | (nullptr) | ... // after `camA` removal
  (camC) | (camB) | (nullptr) | ... // after `camC` appearance

Note that `device::id` is removed, and the id is now derived from
the position in `impl::devices`.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
db3d91ebeb spa: libcamera: use nullptr instead of NULL 2025-07-15 08:12:54 +00:00
Barnabás Pőcze
4fa11619a2 spa: libcamera: use C++ style casts 2025-07-15 08:12:54 +00:00
Barnabás Pőcze
bb8223bff1 spa: libcamera: use anon ns instead of static
Move most things into anonymous namespaces for internal linkage
instead of using `static`. This shortes declarations and makes it
hard to forget.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
cb71071d93 spa: libcamera: device: remove empty line 2025-07-15 08:12:54 +00:00
Barnabás Pőcze
e19a8bb5cd spa: libcamera: source: inline mmap_init()
The function has a single caller is essentially just a wrapper only
calling `mmap_init()`. So inline it into `spa_libcamera_alloc_buffers()`.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
561a9d6ebb spa: libcamera: source: set "corrupted" flag if applicable
If the libcamera `FrameMetadata` reports anything other than `FrameSuccess`,
then set `SPA_META_HEADER_FLAG_CORRUPTED`, notifying the application that
the frame may be unusable.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
0022fc90b7 spa: libcamera: source: use union for transferring control value
Use a union since only one member is active at a time, and use the
proper `libcamera::ControlType` enum to store the type instead of a
bare number. Also remove an unnecessary cast.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
f94f4de6ff spa: libcamera: source: simplify control mapping
Remove the `impl` parameter as it is not used, and use C++ range
based for loops.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
311b3cc37f spa: libcamera: source: do not make expensive queries multiple times
`StreamFormats::pixelformats()` and `StreamFormats::sizes()` both
return newly created `std::vector`s, so do not call them multiple
times.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
489cc49937 spa: libcamera: source: simplify format lookup
Use range based for loops instead of indices.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
0ea7dc9f19 spa: libcamera: source: use enum types
Use the appropriate enum types instead of bare `uint32_t`,
this provides better type safety in C++.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
f53ac8d57c spa: libcamera: source: handle camera acquire failure
Check the return value of `Camera::acquire()` and return the error
if that fails.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
1a1cf55efb spa: libcamera: inline libcamera-utils.cpp
The file is not useful without `libcamera-source.cpp` because it
uses symbols only defined there. And being a non-self-contained
source file, it also breaks clangd. So move its contents directly
to `libcamera-source.cpp`. This makes the file about 2200 lines long,
but I feel that is still manageable (and it is by far not the longest).
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
5a9cdd724f spa: libcamera: clean up includes
Remove some unnecessarily includes.
2025-07-15 08:12:54 +00:00
Barnabás Pőcze
5f4f4b5dd3 spa: libcamera: use lock when acquiring CameraManager
Make `libcamera_manager_acquire()` thread safe by locking a mutex
when the `CameraManager` instance is created and started.
2025-07-15 08:12:54 +00:00
Pauli Virtanen
cee0c39b00 bluez5: fix decode-buffer buffering threshold
The minimum is the number of requested samples, not duration, which can
be different when resampling.
2025-07-12 19:59:33 +00:00
Pauli Virtanen
ff81fc9f7b bluez5: fix ISO sequence numbering
Pass zero-length packets to the codec. BAP/ISO may use these to indicate
missing data.

Fix A2DP codecs to not parse input with spa_return_val_if_fail, that's
meant for assertions. Just return -EINVAL directly, it's normal that
input data may contain garbage.
2025-07-12 19:59:33 +00:00