Commit graph

14098 commits

Author SHA1 Message Date
Wim Taymans
e35a8554f8 control: improve UMP to Midi conversiom
Improve the spa_ump_to_midi function so that it can consume multiple UMP
messages and produce multiple midi messages.

Some UMP messages (like program changes) need to be translated into up
to 3 midi messages. Do this byt adding a state to the function and by
making it consume the input bytes, just like the spa_ump_from_midi
function.

Adapt code to this new world. This is a little API break..
2025-08-19 18:33:59 +02:00
Wim Taymans
bf10458604 tools: handle both Midi and UMP when recording
The midifile can handle both UMP and Midi formats when saving so allow
this here.
2025-08-19 18:33:59 +02:00
Wim Taymans
15f3b1f450 tools: add -m options to mididump
The -m option forces conversion to MIDI 1.0 and will then dump the midi
1 events.
2025-08-19 18:33:59 +02:00
Wim Taymans
c0a7c01a35 midifile: fix seeking in midifile
When we perform a seek, we need to update the current position in the
file as well or we calculate wrong offsets.
2025-08-19 18:33:58 +02:00
Wim Taymans
f562394596 alsa-seq: improve debug
Make it easier to change the event debug. Also add some more context
to the event debug.
2025-08-19 18:33:58 +02:00
Jordi Mas
0aff6e0ef0 Update Catalan translation 2025-08-18 11:58:40 +00:00
Wim Taymans
5153dc3362 stream: emit RUNNING state from Start
cd68819feb added code to follow the state
change of the node because at the time it the Start code was async and
it was better to complete it before emitting the state.

9b80855821 however made the Start command
sync again and so we can safely emit the running state in the Start.

The effect is that the Running state change is emitted first and then
the node eventfd is added to the data loop that can then call the process
callback. Having the process callback happen before the RUNNING state
change is unexpected and racy.
2025-08-18 13:40:01 +02:00
Wim Taymans
3643c468e4 impl-port: keep auto-generated port.alias in sync
When the port.alias was auto-generated from the port.name, make sure we
update it when the port.name changes.

See #4851
2025-08-18 11:28:15 +02:00
Wim Taymans
1d437dfb8e global: allow property updated for registered globals
The idea of fd2db174c1 was to allow for
property updates after the global was registered but this check was not
removed to actually make this happen.

Fixes #4851
2025-08-18 11:25:50 +02:00
Robert Mader
e8ae244b2b gst: src: Promote 'set format' log to info
Follow various other elements like glupload and gtk4paintablesink and
print the negotiated caps at a higher priority than debug. A small
quality of life improvement to facilitate debugging.
2025-08-13 22:41:38 +02:00
Barnabás Pőcze
b82160c2e7 spa: libcamera: source: remove stale data from buffers
When clearing the buffers, remove the stale pointers and file descriptors
as accidental reuse of those is problematic and potentially difficult to
diagnose. Do this for every data plane.

Also clear the node's `buffer` structures to remove any references to
the provided `spa_buffer` objects and related metadata.
2025-08-13 17:57:30 +02:00
Barnabás Pőcze
bf327d3dfb spa: libcamera: source: simplify spa_libcamera_clear_buffers()
Remove the unused `impl` parameter and the unnecessary early return.
2025-08-13 17:56:48 +02:00
Barnabás Pőcze
b948ffdb25 spa: libcamera: source: remove SPA_DATA_MemPtr support
The current handling of `SPA_DATA_MemPtr` is not entirely correct because
its handling of multi-planar buffers is not appropriate: it leaks memory
mappings because it overwrites `buffer::ptr` for each plane.

Since this data type should not really be in use in normal deployments,
let's remove it for now.
2025-08-13 17:56:44 +02:00
Barnabás Pőcze
3e28f3e859 spa: libcamera: source: rework startup sequence
After e0e8bf083 ("spa: libcamera: source: create eventfd before starting camera"),
things are still not entirely correct. This change ensures that if starting
the camera fails, then the runtime state, most importantly the ring buffer
of completed requests is restored to its initial state.

Furthermore, it is also ensured that `impl::active` can never be observed
by the data thread while it is being changed, which is achieved by setting
it before/after adding/removing the event source.
2025-08-13 10:24:24 +02:00
Barnabás Pőcze
507688e6c9 spa: libcamera: source: add eventfd to loop while locked
While concurrent `spa_loop_add_source()` invocations work with the current
main epoll-based implementation, this is not guaranteed, so lock the loop.
Similarly to how it is done elsewhere and for removal already.
2025-08-13 10:24:16 +02:00
Barnabás Pőcze
1f60cd291f spa: libcamera: source: keep libcamera::FrameBufferAllocator
Instantiate it once and keep it instead of always dynamically
allocating it when the camera is acquired.
2025-08-13 10:24:05 +02:00
Barnabás Pőcze
c517e712ed spa: libcamera: source: clear buffers when format is changed
pipewire assumes that the buffers are removed from a port when its format is
changed even without an explicit call to `port_use_buffer()`.

So if the format is not just tested, clear the buffers, as well as the libcamera
requests and buffers because they are also recreated when a new format is set.
This matches the behaviour of the v4l2 plugin. Furthermore, this change also
removes the call to `spa_libcamera_use_buffers()` because that function does
nothing. And finally this change necessitates that the current format is always
reset (when not testing), not just before reaching `spa_libcamera_set_format()`.
2025-08-13 10:24:01 +02:00
Barnabás Pőcze
31176120f5 spa: libcamera: source: handle try-only format unset
Do nothing if `format == nullptr` and `SPA_NODE_PARAM_FLAG_TEST_ONLY` is present.
2025-08-13 10:23:57 +02:00
Barnabás Pőcze
a8a60832cd spa: libcamera: source: do not emit param change if try-only
If `SPA_NODE_PARAM_FLAG_TEST_ONLY`, then the format does not change
on the node, it is only tested. So do not emit the param change events.
2025-08-13 10:23:52 +02:00
Barnabás Pőcze
dac9e40be6 spa: libcamera: source: extract presence of SPA_NODE_PARAM_FLAG_TEST_ONLY
Use a boolean named `try_only` instead of checking `flags` each time.
2025-08-13 10:23:46 +02:00
Barnabás Pőcze
05a9e52caf spa: libcamera: source: remove format config shortcut
Remove the code that is supposed to compare the current and the to-be-set
format for returning early if they match. This is removed:

  * v4l2 also does not have it either;
  * it needs more consideration (there are not properly handled fields);
  * it would make later changes somewhat more complicated.
2025-08-13 10:23:42 +02:00
Barnabás Pőcze
25075bb3d7 spa: libcamera: source: set chunk flags on error
Set `SPA_CHUNK_FLAG_CORRUPTED` if the frame buffer metadata
signals anything other than success.
2025-08-13 10:23:36 +02:00
Barnabás Pőcze
019a5c130f spa: libcamera: source: process requests on data loop
Since `impl::requestComplete()` runs in an internal libcamera thread, extra care
would need to be taken to validate all accesses to common data structures. For
example, the function might call `spa_libcamera_buffer_recycle()`, which accesses
`impl::ctrls`, which would be unsafe because it could read or modified at the same
time on the data thread. So move the processing of requests to the data loop.
2025-08-13 10:23:32 +02:00
Barnabás Pőcze
22ddb88072 spa: libcamera: source: process all requests in the ring buffer
It is possible that multiple requests complete before the data loop can run
`libcamera_on_fd_events()`. However, previously only the earliest item was
processed from the ring buffer, meaning that in those cases request processing
could be lagging request completion by multiple requests.

Fix that by getting the number of available requests and processing them all.
2025-08-13 10:23:28 +02:00
Barnabás Pőcze
c01a2977a5 spa: libcamera: source: reset ring buffer when stopping
Presently, the ring buffer of completed requests is only cleared
when the buffers are removed from the port. This is not entirely
correct since pause/start commands do not clear the buffers but
they stop the camera. As a consequence, it is possible that some
completed requests stay in the ring buffer, causing them to be
mistakenly processed when the camera is started next.

So reset the ring buffer after the camera is stopped, the same time
as the queue of free buffers is cleared.
2025-08-13 10:23:22 +02:00
Barnabás Pőcze
72fd462090 spa: libcamera: source: move request completion data to impl
A `libcamera::Request` is directly tied to the camera, not any ports ("streams")
of it. So move the request completion ring buffer into the `impl` struct.

This is a prerequisite for supporting multiple libcamera streams (~ exposing
multiple ports on the node) in the future.
2025-08-13 10:23:17 +02:00
Barnabás Pőcze
099292d63d spa: libcamera: source: store the request pointer in ring buffer
The request will be needed later, so store that directly in the
completion ring buffer for easy access.

This is fine even though `impl::requestComplete()` calls `Request::reuse()`
because only the request cookie is used in `libcamera_on_fd_events()` and
that remains constant during the lifetime of a request object.
2025-08-13 10:23:13 +02:00
Barnabás Pőcze
68627c5563 spa: libcamera: source: remove impl::pendingRequests
The handling of `impl::pendingRequests` is a bit problematic because,
for example, during startup, if `spa_libcamera_buffer_recycle()` observes
that `impl::active == false`, then it will try to append to `impl::pendingRequests`,
which is being iterated in the main thread in `spa_libcamera_stream_on()`.
That is not allowed on an `std::deque`.

So instead remove it altogether, and simply queue all requests when starting.
After `libcamera::Camera::stop()` returns, every request is guaranteed not
to be used by libcamera, and they can be freely reused, so this is safe to do.

This also removes the need for calling `spa_libcamera_buffer_recycle()` when
the buffers are set/unset on a port since that function no longer changes
anything apart from updating `buffer::flags` but `spa_libcamera_alloc_buffers()`
is modified appropriately to take care of that. And in the case of
`spa_libcamera_clear_buffers()` clearing the flag is not required because the
next `spa_libcamera_alloc_buffers()` call will reset reset the flags.
2025-08-13 10:23:09 +02:00
Barnabás Pőcze
475665d615 spa: libcamera: source: persistent requests <-> buffer association
Currently only a single stream is used. This makes it easy to associate
each request with the appropriate frame buffer when it is created. In
turn, this makes reusing requests a bit simpler and a bit more efficient.

So do that: add buffers to requests when they are allocated in `allocBuffers()`.
2025-08-13 10:23:05 +02:00
Barnabás Pőcze
29b0c87d71 spa: libcamera: source: allocBuffers(): more error checking
First, check if the request pool is empty, and signal an error if it
is not. Second, ensure that the number of allocated buffers matches.
2025-08-13 10:23:01 +02:00
Barnabás Pőcze
348e703be0 spa: libcamera: source: allocBuffers(): restore on failure
Undo the allocation and clear the requests if a failure is encountered
in order to leave things in a known state.
2025-08-13 10:22:57 +02:00
Barnabás Pőcze
b9b7c0ab05 spa: libcamera: source: freeBuffers(): call when format is unset
At the moment the libcamera buffer allocation is completely tied to format
negotiation. `freeBuffers()` undoes `allocBuffers()`. And `allocBuffers()`
is called as part of `spa_libcamera_set_format()`. Therefore `freeBuffers()`
should be called independent of the state of the buffers on any port.

Otherwise unsetting the format while there are no buffers on the port will
cause the libcamera requests and buffers not to be released correctly. Similarly,
removing the buffers from a port would clear the libcamera requests and buffers,
making the node unusable without setting a new format.
2025-08-13 10:22:53 +02:00
Barnabás Pőcze
89545946fd spa: libcamera: source: freeBuffers(): split pending request removal
`freeBuffers()` should undo exactly what `allocBuffers()` does. However,
it currently also clears `impl::pendingRequests`, but that is filled
by `spa_libcamera_buffer_recycle()` during `spa_libcamera_alloc_buffers()`.

So remove the clearing of `impl::pendingRequests` from `freeBuffers()` and
move it directly into `spa_libcamera_clear_buffers()`.
2025-08-13 10:22:50 +02:00
Barnabás Pőcze
14e0a8f66f spa: libcamera: source: propagate error when setting format
If `spa_libcamera_set_format()` fails, propagate its return value
as is without rewriting it to `EINVAL`.
2025-08-13 10:22:46 +02:00
Barnabás Pőcze
47ee86938b spa: libcamera: source: port_set_format(): remove goto
Remove the `done` label by moving things into the `format != nullptr` branch.
2025-08-13 10:22:41 +02:00
Barnabás Pőcze
860e455440 spa: libcamera: source: support libcamera::formats::R8
Map `libcamera::formats::R8` to `SPA_VIDEO_FORMAT_GRAY8`.
2025-08-13 09:46:56 +02:00
Sertonix
3914d0cab3 module-jack: fix name of LIBJACK_PATH environment variable
Fixes 0629647cb5 module-jack: load libjack.so.0 with dlopen
2025-08-13 07:15:16 +00:00
Barnabás Pőcze
0fcabdbd0c ci: cross compile on debian 13 to multiple architectures
Debian supports many architectures, and it is relatively easy to work
with multiarch packages, and finally `meson env2mfile` supports
generating cross files with the `--debarch` option.

Previously only native builds were done in the CI, so use debian to
build pipewire for multiple architectures.

Some packages are unfortunately not multiarch compatible, so a separate
container is built for every architecture.
2025-08-13 07:14:33 +00:00
Barnabás Pőcze
9438df8d30 Revert "ci: Add an x86 build"
This reverts commit 2042a0483b.
A new approach is added in subsequent commits based on debian
for more architectures.
2025-08-13 07:14:33 +00:00
Barnabás Pőcze
fcb318b9c5 pwtest: is_debugger_attached(): rework test
Check if the "TracerPid" field in `/proc/self/status` is non-zero. This does
not need libcap, and does not depend on capabilities, and it also works under
qemu user emulation.
2025-08-13 07:14:33 +00:00
Barnabás Pőcze
0d0108e954 test: spa-utils: utils_snprintf_abort_neg_size: remove valgrind check
Death tests are always skipped by the framework when running on valgrind,
so there is no need for the check.
2025-08-13 07:14:33 +00:00
Frédéric Danis
a50b66651e bluez5: backend-native: Add log for call state changes
This also to track each call state changes.
2025-08-12 18:22:40 +03:00
Frédéric Danis
1ad3fdff8a bluez5: backend-native: Free command list queue on RFComm free
When RFComm conection is closed or lost, the pending commands should
be freed, and if a DBus message is attached an error reply should be
sent.
2025-08-12 11:35:02 +02:00
Pauli Virtanen
618d60a1f2 alsa: show correct value in api.alsa.period-num 2025-08-09 12:53:41 +03:00
George Kiagiadakis
22e80e228c bluez5: backend-native: reset hfp_hf_in_progress state on error reply
If a AT+CHLD command fails, we may get stuck in the "in progress" state
forever unless we clear the state here.
2025-08-09 09:24:02 +00:00
Pauli Virtanen
a39462a6c0 bluez5: support 44.1kHz rate for BAP LC3
liblc3 doesn't support 44.1kHz directly, but its authors write one
should just use some nearby rate instead. Do just that.
2025-08-09 11:30:40 +03:00
Wim Taymans
206a30d100 examples: the example generates UMP 2025-08-08 15:10:56 +02:00
Barnabás Pőcze
9aeba05e47 spa: libcamera: source: rework control setting
Instead of applying each control separately, collect them into a
`libcamera::ControlList`, and try to apply them at the end.

Furthermore, instead of doing a blocking loop invoke, use `spa_loop_locked()`
as it is sufficient to update `impl::ctrls`.

After this change control setting works in a more "atomic" way since every
control is parsed and checked before actually reaching the camera. It is
also detected if the given control is not supported by the camera.
2025-08-07 07:59:54 +00:00
Niklas Carlsson
30ba62e47c filter-graph: set NULL data support in LV2
In LV2, a port supports NULL data if the connectionOptional
property is set.
2025-08-06 12:09:13 +02:00
Niklas Carlsson
2ac708d916 filter-graph: add NULL data support per port
It would be good to define NULL support per port in e.g. LV2
plugins where sidechains are usually defined optional.
2025-08-06 12:08:23 +02:00