Commit graph

645 commits

Author SHA1 Message Date
Wim Taymans
818d1435ce treewide: access the position information using helpers
Make sure we don't access out of bounds and that we use the helpers
wherever we can to access the position information.
2025-10-21 13:06:25 +02:00
Wim Taymans
8bbca3b8f3 spa: add spa_audio_parse_position_n
Add a function that accepts the size of the position array when reading
the audio positions. This makes it possible to decouple the position
array size from SPA_AUDIO_MAX_CHANNELS.

Also use SPA_N_ELEMENTS to pass the number of array elements to
functions instead of a fixed constant. This makes it easier to change
the array size later to a different constant without having to patch up
all the places where the size is used.
2025-10-21 09:59:13 +02:00
Wim Taymans
13b8c23767 Don't use SPA_AUDIO_MAX_CHANNELS directly
Make a MAX_CHANNELS define and use that one in code. This makes it
easier to change the constant later.
2025-10-21 09:43:06 +02:00
Barnabás Pőcze
e72962fb42 pw-cat: do not use deprecated FF_PROFILE_*
These macros were deprecated in 2023[0], and are absent in the latest
ffmpeg 8.0[1]. So use the new names.

[0]: 8238bc0b5e
[1]: 8224327698
2025-10-06 12:10:23 +00:00
Wim Taymans
fe78e80614 tools: fix compilation after removal of field 2025-10-02 16:39:18 +02:00
Wim Taymans
19198d2982 pw-cat: fix DSD file reading
Now that the server asks for the right amount of samples for DSD, just
give it the right amount of samples without doing some weird scaling.

Make a method to calculate the size (stride) of one sample, which
depends on the interleave and channels of the stream.

See !2540
2025-09-25 13:56:51 +02:00
Wim Taymans
f89428d9f8 tools: print async node state in pw-top
Pass the node async state in the profiler and use this in pw-top to draw
the node with = instead of a + in the tree when it's async.
2025-09-15 12:29:57 +02:00
Wim Taymans
0877eba761 tools: add Latency reporting to pw-link
Rework how the monitor mode works. Instead of having separate paths for
the list and monitor mode, reuse the list mode. We simply mark all
changes and then list the changes in a loop.

This makes it possible to accumulate some updates and print them
together.

Add a -t option to list the latency params on a port.
2025-09-03 14:42:23 +02:00
Wim Taymans
8425307ca1 tools: fix compilation on alpine 2025-08-29 17:59:00 +02:00
Wim Taymans
9eb6cda245 tools: add pw-midi2play and pw-midi2record aliases
And update the documentation.
2025-08-29 17:43:13 +02:00
Wim Taymans
eda3290883 tools: add midi clip support
The SMF2 CLIP format is the official container for storing MIDI 2.0
messages.

Add support in mididump and pw-cat.
2025-08-29 17:34:34 +02:00
Wim Taymans
b192099353 tools: don't generate error when closing read midi file 2025-08-29 17:01:29 +02:00
Wim Taymans
4b177f4557 tools: add guards around header include 2025-08-29 17:00:41 +02:00
Wim Taymans
70ec3aec64 tools: debug utility messages better 2025-08-29 17:00:06 +02:00
Wim Taymans
ddc5c17163 tools: move midievent to separate file 2025-08-28 18:05:36 +02:00
Torkel Niklasson
1ce85ee2ae tools: add -n option to pw-cat
Add sample limit switch -n to pw-cat to stop the recording or playback
after a set number of samples received.

Change-Id: Iaa551db9849acd6acdb6897dbfaa92a21afa1312
2025-08-28 16:04:47 +00:00
Wim Taymans
7359491b97 tools: dump sndfile loginfo on error when verbose 2025-08-26 10:59:11 +02:00
Arun Raghavan
28ed09b155 tools: Fix -C handling for pw-dump
The short form needs to have a :: to signal an optional argument so
that something like -Calways can work.
2025-08-25 09:48:47 -04:00
Wim Taymans
b7412169f5 tools: Use the same -M option as pw-cat to force midi 2025-08-20 10:00:07 +02:00
Wim Taymans
00bb29de0f tools: add -M option to pw-cat and friends
It forces conversion to or from UMP. By default, the events will be
converted to UMP before injecting them into the graph.
2025-08-19 18:34:00 +02:00
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
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
Wim Taymans
5743849b50 tools: use safer spa_pod_parser for control events 2025-07-30 19:08:36 +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
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
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
b3bf5be1f6 *: Avoid macros that use casts where possible
Use direct field access when the type is known, instead of a macro that
includes a cast.

These were missed in e4fcbef89a.
2025-07-10 14:02:55 +00:00
Wim Taymans
343509abdf pw-cli: add type info to variables
Add type info to variables. This way we can avoid doing things on
variables of the wrong type.

Add a list-vars command to list the currently registered variables and
their type.

Fixes #4746
2025-06-18 15:02:20 +02:00
Wim Taymans
58aab3e16b pw-dump: add -i and -s options
-i can be used to configure the indentation (default 2)
-s can be used to output simplified SPA JSON
2025-06-17 11:01:28 +02:00
Pauli Virtanen
baadda3b67 tools: fix some missing free/close 2025-06-14 15:21:29 +03:00
Sam James
2cec77e7df *: unify config.h handling
config.h needs to be consistently included before any standard headers
if we ever want to set feature test macros (like _GNU_SOURCE or whatever)
inside. It can lead to hard-to-debug issues without that.

It can also be problematic just for our own HAVE_* that it may define
if it's not consistently made available before our own headers. Just
always include it first, before everything.

We already did this in many files, just not consistently.
2025-05-30 10:24:13 +00:00
Carlos Rafael Giani
e2731914ad pw-cat: Document numeric WMA constants 2025-05-29 22:24:31 +02:00
Carlos Rafael Giani
7341cc401b pw-cat: Add support for AC3, EAC3, TrueHD, DTS, MPEG-H 2025-05-29 22:24:07 +02:00
Wim Taymans
96007dc576 pw-cat: mode SYSEX mode out of ffmpeg define 2025-05-26 19:24:23 +02:00
Wim Taymans
737ca4ee7b tools: add sysex play option in pw-cat
This makes it possible to upload raw midi (sysex) into the graph.
2025-05-23 16:52:22 +02:00
Wim Taymans
564c9b1ba5 Use "8 bit raw midi" for control ports again
There is no need to encode the potential format in the format.dsp of
control ports, this is just for legacy compatibility with JACK apps. The
actual format can be negotiated with the types field.

Fixes midi port visibility with apps compiled against 1.2, such as JACK
apps in flatpaks.
2025-05-23 16:46:13 +02:00
Wim Taymans
6b3681938b pw-dump: don't do raw mode when streaming
pw-dump | less -RS is a common thing and raw mode is not helpful.
2025-05-13 14:59:51 +02:00
Wim Taymans
08efc1171c pw-dump: disable indent in raw mode as well 2025-05-13 10:37:00 +02:00
Kirill
1f16f949ec Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
2025-05-13 08:27:29 +00:00
dartvader316
d599936925 pw-dump: add raw json elements output option 2025-05-13 08:27:29 +00:00
Wim Taymans
b47d28bad6 profiler: use doubles in profiler.log
Don't truncate the measurements when we convert to usec but keep the
fractional part to get a more accurate graph.
2025-05-12 17:23:35 +02:00
Wim Taymans
2ea8d3430c tools: add c key to reset ERR counters
Reset the ERR counters when pressing the c key. This only makes the
current pw-top start counting from 0 again, it does not change anything
globally on the server. It's still usefull because you can use it to
let it count the number of new errors since the keypress.
2025-04-30 15:10:15 +02:00
Wim Taymans
55f71520db midifile: unpack the UMP SysRT bytes correctly
They are packed in a native endian uint32_t so read it like that and
then use shifts to get the right bytes.
2025-04-16 18:33:36 +02:00
Simon Ruderich
c4a88dfe6c midifile: decode UMP SysRT messages 2025-04-16 17:57:44 +02:00
Pauli Virtanen
42b92a3487 pw-loopback: add missing --channel-map long option 2025-04-09 07:47:32 +00:00
Wim Taymans
b238c9d7a1 pw-cat: improve sndfile file format debug info
Print the endianness, container name and the sample format nicely
instead of dumping the hex values.
2025-03-24 18:49:41 +01:00