Commit graph

7238 commits

Author SHA1 Message Date
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
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
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
Wim Taymans
206a30d100 examples: the example generates UMP 2025-08-08 15:10:56 +02:00
Carlos Rafael Giani
97a1609b29 module-rtp: Reset ring buffer contents when stream starts 2025-08-05 17:54:56 +00:00
Carlos Rafael Giani
c9a8b8629f module-rtp: Limit actual max buffer size to an integer multiple of stride
Opus and MIDI code get TODOs added, since it is currently unclear how to
implement that fix for them.
2025-08-05 17:54:56 +00:00
Carlos Rafael Giani
e5be9cce4f module-rtp: Reorder sync checks and resynchronization code
This fixes the case when synchronization is established but actually not
valid anymore. In such a case, the code would _first_ write to the ring
buffer (at the wrong position due to the invalid sync), and _then_ detect
the bogus synchronization. Reorder the code blocks to _first_ check the
current sync, then resynchronize if neeeded (or perform initial sync if
no sync is established yet), and _then_ write to the ring buffer.
2025-08-05 17:54:56 +00:00
Carlos Rafael Giani
b8d98d03fe module-rtp: Fix timestamp check and add discontinuity check
Until now, the timestamp check was comparing the timestamp delta against
the value of the "quantum" variable. However, the timestamps use clock
samples as units, while the "quantum" variable uses nanoseconds. The
outcome is that this check virtually never returned true. Use the
spa_io_clock duration instead of that quantum nanosecond duration to make
the check actually work.

Also, do not just rely on vast timestamp deltas to detect discontinuities;
instead, check first for the presence of the SPA_IO_CLOCK_FLAG_DISCONT
flag to detect said discontinuities.
2025-08-05 17:54:56 +00:00
Carlos Rafael Giani
2a460e18e3 module-rtp: Rename timestamp to actual_timestamp for clarity 2025-08-05 17:54:56 +00:00
Jan Grulich
3c759ae293 Add IWYU annotations
This allows to use clang-include-cleaner tool without <pipewire/foo.h>
headers being automatically added when <pipewire/pipewire.h> is included
instead.

See https://issues.webrtc.org/issues/422940461
2025-08-05 17:51:13 +00:00
Barnabás Pőcze
58d86cfb5f pw-cli: print pw_core errors
At the moment errors are printed using `pw_log_error()`, however, that does
not display them by default because `client.conf` sets `log.level=0`.

Use `fprintf()` and always print the errors.
2025-08-04 08:28:10 +00:00
Barnabás Pőcze
5ecf27681e pipewire: module-rt: acquire_rt(): return error if thread not found
Instead of implicitly acting on the current thread if the provided thread
handle is unknown, return an error. This behaviour is not depended on inside
pipewire, and if needed, special casing e.g. `thread == NULL` could be added,
but any random `thread` value shouldn't affect the current thread.
2025-08-01 21:42:32 +02:00
Wim Taymans
35b3c8c279 vban: truncate sess.name when too large 2025-08-01 18:17:21 +02:00
Wim Taymans
88d7d5706a conf: fix priority of the overrides
A config file with a higher level should override one with a lower
level.

Fixes #4816
2025-08-01 10:49:26 +02:00
Wim Taymans
8495bffee5 modules: use safer pod parsing for control sequence 2025-07-31 11:50:11 +02:00
Wim Taymans
5743849b50 tools: use safer spa_pod_parser for control events 2025-07-30 19:08:36 +02:00
Carlos Rafael Giani
91ebfac75b module-rtp: Clear after reading in direct timestamp mode 2025-07-29 17:24:09 +02:00
Wim Taymans
e317edcfb9 pod: rework the parser
Make a new body.h file with some functions to deal with pod and their
body. Make the iter.h functions use mostly this.

Rework the parser so that it only uses body.h functions. With the separation
of pod+body, we can read and verify the pod once and then use the
verified copy to handle the rest of the body safely.

We do this because iter.h only works in pods in memory that doesn't change
because it is vulnerable to modifications of the data after verifying it.

The new parser is not vulnerable to this and will not cause invalid
memory access when used on shared memory. There is however no need for
atomic operations to read the headers, whever is read is either valid
and useable of invalid and rejected.

See #4822
2025-07-29 15:15:02 +02:00
Wim Taymans
e2c291d18e pw-top: reduce flicker when updating
Use wearase() instead of wclear() before redrawing

Fixes #4818
2025-07-29 14:57:04 +02:00
Wim Taymans
1957d3fb00 pulse: avoid a compiler warning 2025-07-25 17:37:56 +02:00
Demi Marie Obenour
9e789c65c2 src: check that POD arrays have the correct size for their type
The parser does not check that POD arrays have the correct size for
their type, so the calling code must do that.

This also enumerates some of the code that cannot handle the size of the
values of an array not being the exact expected size for its type.
There is a lot of it.
2025-07-24 16:27:42 -04:00
Wim Taymans
42b779974c module-rtp: don't leak opus codec and ptp_sender
Add a deinit() function and use it to free the opus codec we created in
init().

Also free the ptp_sender when it was created.
2025-07-24 13:16:15 +02:00
Carlos Rafael Giani
2bcc8589fa module-rtp: Fix and improve direct timestamp mode and documentation
Direct timestamp mode was incorrectly using over/underrun detection logic
and fill level tracking logic that is actually meant for the other mode
(referred to from now on as "constant latency mode"). Over/underruns are
tracked implicitly in the direct timestamp mode, and the absolute fill
level is not relevant in that mode, since the latency is not needed to
be constant then.

Also improve log lines and the RTP module documentation to define these
buffer modes clearly and explain their differences and use cases.

Opus and MIDI code get TODOs added, since their direct timestamp mode
implementations still may be incorrect. Fixing those will be done in
a separate commit.
2025-07-24 07:28:53 +00:00
Martin Geier
f8b0d0a43c rtp: include stream delay to a read position
When a stream has some delay, a time t1 + delay has to be read in time
t1 to play it when expected.
Decrease target_buffer by delay to start playback sooner, so sound
is played at correct time when delay is applied.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2025-07-24 07:28:53 +00:00
Wim Taymans
b52c490709 resample: fix compilation
Also fix a compiler warning in clang
2025-07-23 12:52:27 +02:00
Wim Taymans
c54d3764b2 stream: update the docs a little
Give some more information about the delay field and how it can be
negative.
2025-07-23 12:46:45 +02:00
Wim Taymans
dd9d8038da client-node: close SyncObj fd as well
We also need to close the SynObj fd we got, just like we close any
DmaBuf or MemFd.

Make sure we get a compiler error when we add more items to the
data type enumeration later.

Fixes #4807
2025-07-22 14:00:09 +02:00
Barnabás Pőcze
e6e36c4d34 tests: endpoint: fix valgrind uninit warning
Previously, valgrind was warning that

  Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)

this was caused by uninitialized values being serialized for IPC.
Specifically, not all members of the `pw_endpoint_info` struct were
initialized, which caused uninitialized bytes to end up in the IPC
buffers due to the `pw_endpoint_emit_info()` in `endpoint_add_listener()`.

Fix that by initializing the missed `id` and `flags` members.
2025-07-20 18:36:20 +02:00
Barnabás Pőcze
f2c878a2c1 meson.build: rework systemd related options
One issues is that the `systemd-{system,user}-service` feature options
do not anything without the `systemd` option. This makes it more
complicated to arrive at the desired build configuration since there
are 3^3 = 27 possible ways to set each of them, but if `systemd=disabled`,
then the other two are just ignored.

Secondly, the `systemd` option also influences whether or not libsystemd
will be used or not. This is not strictly necessary, since the "systemd"
and "libsystemd" pkg-config files might be split, and one might wish to
disable any kind of service file generation, but use libsystemd.

Solve the first issues by using the `systemd-{system,user}-service` options
when looking up the "systemd" dependency for generating service files. This
means that the corresponding option is in full control, no secondary options
are necessary. This means that the "systemd" dependency is looked up potentially
twice, but that should not be a significant issue since meson caches dependecy
lookups.

And solve the second issue by renaming the now unused `systemd` option to
`libsystemd` and using it solely to control whether or not libsystemd will
be used.

Furthermore, the default value of `systemd-user-service` is set to "auto" to
prevent the dependency lookup from failing on non-systemd systemd out of
the box. And the journal tests in "test-support" are extended to return "skip"
if `sd_journal_open()` returns `ENOSYS`, which is needed because "elogind"
ships the systemd pkg-config files and headers.
2025-07-18 09:46:17 +00:00
Carlos Rafael Giani
97996a6e20 module-rtp-sap: Take RTP dest port into account when matching sessions
This is important if several sessions use the same multicast IP address.
2025-07-18 10:54:04 +02:00
Carlos Rafael Giani
1c991a329e pw-cat: Use multiple encoded frames if single frames don't fill the quantum 2025-07-18 10:53:43 +02:00
Melvin Manninen
f4f548fbe6 module-rtp-sap: Fix Message Identifier Hash generation for first session and update SDP on grandmaster change 2025-07-17 16:00:32 +00: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
Demi Marie Obenour
b8e29d471b module-rtp: Fix bounds checks in MIDI parsing
These are potential security problems.
2025-07-15 10:46:10 +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
Barnabás Pőcze
90c0d8c225 pipewire: module-rt: use pw_thread_utils_join()
`pw_thread_utils_create()` is used to create the thread, so use
the corresponding `pw_thread_utils_join()` instead of just
`pthread_join()`.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
a55561dcba pipewire: module-rt: destroy mutex and condition variable 2025-07-12 19:55:34 +00:00
Barnabás Pőcze
0923e12fa3 pipewire: module-rt: have just one impl_thread_utils
There are two definitions depending on `#ifdef HAVE_DBUS`,
however, the two definitions are indentical, so remove one.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
b124385fac pipewire: module-rt: remove sched_set_nice()
It has only a single caller, so inline it because
there is not much point in keeping it separate.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
b71d0224db pipewire: module-rt: remove check for impossible condition
Neither `sched_set_nice()` nor `pw_rtkit_make_high_priority()`
(should) ever return a positive number, so that case is not
possible; remove it.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
7a336645fb pipewire: module-rt: get_rtkit_priority_range(): return void
This function cannot fail, so make it return `void`.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
801ac5ced8 pipewire: module-rt: simplify check_rtkit()
The return value is always 0, and the `impl` parameter
is not used, so ues the return value to return the boolean
result instead of an out parameter, and get rid of the
unused argument.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
10161407ff pipewire: module-rt: move RLIMIT_RTTIME compat definition
Move it next to the other macros.
2025-07-12 19:55:34 +00:00
Barnabás Pőcze
f0579b9b67 pipewire: module-rt: deduplicate log message 2025-07-12 19:55:34 +00:00