Commit graph

40 commits

Author SHA1 Message Date
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
Wim Taymans
f2452a6af7 spa: some more invoke -> locked calls 2025-05-29 10:17:16 +02:00
Wim Taymans
e2991f6398 json: add helper function to parse channel positions
Use the helper instead of duplicating the same code.

Also add some helpers to parse a json array of uint32_t

Move some functions to convert between type name and id.
2024-09-18 09:54:34 +02:00
Wim Taymans
cd81b5f39a spa: add spa_json_begin_array/object and relaxed versions
Add spa_json_begin_array/object to replace
spa_json_init+spa_json_begin_array/object

This function is better because it does not waste a useless spa_json
structure as an iterator. The relaxed versions also error out when the
container is mismatched because parsing a mismatched container is not
going to give any results anyway.
2024-09-16 09:50:33 +02:00
Wim Taymans
af310523db spa: improve null-audio-sink channels
We can just update the channels in the props, we don't need an extra
property that can go out of sync with the channels.

See #3931
2024-03-28 17:11:16 +01:00
Pauli Virtanen
e784de3933 spa: use log topics everywhere
Use log topics properly everywhere, convert from "#define NAME".
2024-03-11 18:45:21 +02:00
Jonas Holmberg
00ca590ff6 node-driver, null-audio-sink: Fix EAGAIN check
spa_system_timerfd_read() returns -EAGAIN.
2023-09-04 13:24:30 +02:00
Wim Taymans
736e9cc94c null-audio-sink: make it possible to override node.driver
See #3220
2023-05-15 21:25:28 +02:00
Wim Taymans
5ea3c10dca support: sync timers with data loop
Start and stop the timers in the data_loop. Otherwise we might be trying
to stop a timer while the data loop is starting it and we end up with
"ready non-active node" messages.
2023-03-24 17:24:56 +01:00
Wim Taymans
7b6680ba57 plugins: simplify target_ handling
Drivers should only read the target_ values in the timeout, update the
timeout with the new duration and then update the position.

For the position we simply need to add the previous duration to the
position and then set the new duration + rate.

Otherwise, everything else should read the duration/rate and not use
the target_ values.
2023-03-24 11:36:15 +01:00
Wim Taymans
6e8625cf96 node: update the duration/rate from the target
Before scheduling the graph from the driver, update the duration and
rate with the new targets.
2023-03-23 18:39:27 +01:00
Wim Taymans
eca4049a38 null-sink: accept our custom format as well 2023-02-23 12:04:13 +01:00
Wim Taymans
a9756def46 spa: allow passing audio.format to null-sink
So that the EnumFormat returns the given format instead of the default
float ones.
2023-02-23 10:31:51 +01:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
97aafe2234 fix use_buffers checks
We can set 0 buffers even if there is no format.
Return -ENOSPC when too many buffers are set.
2023-01-10 12:30:25 +01:00
Wim Taymans
f44d55f6c2 handle read from timerfd correctly
When reading the timerfd gives an error, we should return right away
because the timeout did not happen.

If we change the timerfd timeout before reading it, we can get -EAGAIN.
Don't log an error in that case but wait for the new timeout.
2022-12-09 17:30:31 +01:00
Wim Taymans
74447acedb Add some more format checks
The format parse functions don't really check if the parsed values
make any sense so we need to to this ourselves.
2022-11-03 13:10:32 +01:00
Wim Taymans
7b432aec88 spa: make default samplerate 48000
Remove some 44100 default rates and use 48000 instead.
2022-09-05 12:21:20 +02:00
Wim Taymans
2fa1b4384b spa: don't warn for NULL io
The io is set to NULL when the port becomes unnegotiated.
2022-09-01 15:31:14 +02:00
Wim Taymans
ffedc2d1e8 null-sink: add option to debug memory 2022-07-04 13:38:07 +02:00
Barnabás Pőcze
60b9d9081b spa: only remove embedded source from data loop from within the loop
Use `spa_loop_invoke()` to invoke a callback on the data loop
to remove an embedded `spa_source` from the data loop.

Embedded `spa_source` objects cannot be safely removed
while the loop is polling without risking potential
use-after-frees.
2022-03-06 18:40:43 +00:00
Wim Taymans
776b52749f Use configured quantum_limit instead of hardcoded value
Parse the quantum_limit parameters and use this to scale the buffers so
that they can contain the maximum allowed samples instead of the
hardcoded 8192 value.

See #1931
2022-01-12 17:50:12 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans
d86008cf8f support: set clock name for null-audio-sink 2021-12-10 12:43:03 +01:00
Wim Taymans
620b34cd6b null-audio-sink: only start timers when driving
Check if we are driving or following and only start the timers when we
are the driver of the graph.

Ready events from non-drivers are not really a problem because they are
ignored. They only cause unnecessary wakeups in the graph.
2021-07-01 11:33:21 +02:00
George Kiagiadakis
c633004bf3 null-sink: make the timerfd non-blocking
Fixes #1377
2021-07-01 11:37:01 +03:00
Wim Taymans
46ef88e520 spa: save the old change_mask and restore when emitting full
When we add a new listener to an object, it will emit the full state
of the object. For this it temporarily sets the change_mask to all
changes. Restore the previous state after this or else we might not
emit the right change_mask for the next listener.

Consider the case where one there are two listeners on an object.
The object emits a change and the first listener wants to enumerate the
changed params. For this is adds a new listener and then triggers the
enumeration. If we set the change_mask to 0 after adding the listener,
the second listener would get a 0 change_mask and fail to update
its state.
2021-05-27 15:21:44 +02:00
Peter Hutterer
95a84e797a treewide: replace !strcmp() with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer
7697ed0757 treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Wim Taymans
b318a9e1d3 support: add right property id 2021-04-01 10:08:47 +02:00
Wim Taymans
fc9a6d6b1e spa: spa_json_get_string does not return the length
The returned string is null terminated.
2021-03-18 18:57:26 +01:00
Wim Taymans
8e590df92f spa: improve info parsing
Make info parsing a bit easier to read by assigning the key and
value to temporary variables.
Improve the parsing of channelmap using json parser to make it
support more cases.
Add a unit test for channelmap parsing options.
2021-03-18 18:40:56 +01:00
Wim Taymans
9662bc96ab null-audio-sink: support and prefer planar F32P
It's easier to convert to and also the native format for the converter
so that it can operate in passthrough mode without any copies.
2021-02-26 21:15:14 +01:00
Wim Taymans
c6f94def08 null-sink: fix null sink scheduling
The null sink pulls in data and provides data after it got the
data in _process.

See #472 #442
2020-12-14 10:21:13 +01:00
Wim Taymans
57886c1198 spa: add audio.position support in null sink 2020-12-02 12:59:50 +01:00
Wim Taymans
4c486c7ae3 spa: remove media.class from null-audio-sink
We can use it with othe media.class values as well
2020-12-02 11:47:08 +01:00
Wim Taymans
d77c563ae8 null-audio-sink: return fixed values for rate/channels when set 2020-11-26 10:21:36 +01:00
Wim Taymans
c3138a9bac spa: make null-sink rate and channels configurable 2020-11-25 21:05:21 +01:00
Wim Taymans
e8640683bb support: add null audio sink 2020-08-20 18:00:00 +02:00