Commit graph

38 commits

Author SHA1 Message Date
Wim Taymans
f7fdafc203 loop: add method to run a function with the lock
Convert some _invoke to _locked
2025-05-29 10:17:16 +02:00
Wim Taymans
ea7e0e9152 spa: revert peer_enum_params node event again
It's not used anymore because it does work so well.

The problem is that while it transparently proxies param enums on
ports to peers, it fails to emit events when those peer
params change in a way that would make the enum result change as well.
This makes it quite hard to use this correctly.
2024-06-20 10:22:45 +02:00
Wim Taymans
fac0d47c23 impl-port: swap io areas instead of doing cycle math
Instead of doing (cycle+1) & 1 for output ports, simply swap the io
areas depending on the port direction (0 = input, 1 = output) and
just to cycle&1 for all ports.
2024-05-08 10:45:53 +02:00
Wim Taymans
04bda2c28c spa: proxy tag and latency to peer of the mixer
We can probably do this better later but right now we do all of the tag
and latency handling bypassing the mixers.

Fixes #3970
2024-04-19 15:32:08 +02:00
Wim Taymans
68916e062b impl-node: implement async scheduling
When node.async is set, make the node async.

Advertize SPA_IO_AsyncBuffers on mixer ports when supported. Set a new
port flag when AsyncBuffer is supported on the port.

When making a link and if one of the nodes is async and the linked ports
support AsyncBuffer, make the link async and set this as a property on
the link. For async nodes we will use SPA_IO_AsyncBuffers on the mixer
ports.

Nodes that are async will not increment the peer required counters. This
ensures that the peer can start immediately before the async node is
ready.

On an async link, writers will write to the (cycle+1 & 1) async buffers
entry and readers will read from (cycle & 1). This makes the readers read
from the previously filled area.

We need to have two very controlled areas with specific rules for who
reads and who writes where because the two nodes will run concurrently
and no special synchronization is possible otherwise.

These async nodes can be paused and blocked without blocking or xrunning
the rest of graph. If the node didn't produce anything when the next
cycle starts, the graph will run with silence.

See #3509
2024-04-18 10:31:29 +02:00
Wim Taymans
77ed5ccb31 spa: give meaning to port_enum_params with SPA_ID_INVALID port_id
This is to iterate params that are common to all ports, such as
EnumFormat or the supported IO areas. Mostly interesting for mixer and
splitter nodes so that we don't have to create a new port just to query
things.
2024-04-17 12:49:13 +02:00
Pauli Virtanen
eaea03c26c spa: export log topic enumerations 2024-01-04 10:02:55 +00:00
Barnabás Pőcze
8256a2d5a6 spa: remove unnecessary indirection for some spa_log_topics
This results in shorter machine code since it removes one
pointer load and a NULL check.
2023-10-06 13:08:24 +00:00
Wim Taymans
69d431acd4 node: clarify port_set_io and SPA_IO_Buffers
port_set_io with SPA_IO_Buffer can be used to enable/disable a port
when the node is running and so the node should make sure the io update
is synchronized with the processing loop.

Use spa_loop_invoke to make sure the mixers handle the port_io updates
correctly.

Setting buffers or a format also needs the port to be disabled so add
some checks for this in the mixers.
2023-09-11 11:23:25 +02:00
Wim Taymans
f99fd7d75a improve some debug 2023-07-19 21:39:12 +02:00
Wim Taymans
baa5497617 spa: warn out of buffers
Running out of buffers is pretty bad and warrants a warning because it
can cause loss of audio.

See #3316
2023-07-07 12:11:02 +02:00
Wim Taymans
8cfa5ccd79 mixer: increase mixer ports from 128 to 512
Don't allocate the mixer arrays on the stack but include in the
implementation structure.
2023-04-21 15:58:38 +02:00
Wim Taymans
a163f29a43 improve logging 2023-03-30 15:03:21 +02: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
9123710971 spa: clean up some port io checks
We should not generate a warning.
2022-09-01 15:39:34 +02:00
Wim Taymans
3c87541219 Revert "mixer-dsp: mix a quantum of data at a time"
This reverts commit ecc0eecf0f.

The io-position is not actually set or updated on the mixer node so it
might use the wrong values.

Fixes #2525
2022-07-18 21:34:57 +02:00
Wim Taymans
f2dee23085 buffer: add EMPTY chunk flag
Add an EMPTY chunk flag to mark a piece of memory as 'empty'. For audio
this means silence.
Use the empty flag to avoid mixing 0 samples.
Set the empty flag in output buffers on audioconvert.
2022-06-24 11:09:01 +02:00
Wim Taymans
ecc0eecf0f mixer-dsp: mix a quantum of data at a time
When there is no input, mix up to a quantum of data. Otherwise we might
send too much data to the next node and cause a delay if it does not
handle this.
2022-06-22 15:50:56 +02:00
Wim Taymans
e1a50a6c1a mixer-dsp: handle input offset
Handle the input buffer offset and clamp the size to maxsize.
2022-05-18 09:24:08 +02:00
Wim Taymans
92198e4d0d spa: clamp required alignment to cpu alignment
pipewire will allocate buffers aligned to the max alignment required for
the CPU. Take this into account and don't expect larger alignment.

Fixes a warning in mixer-dsp when the CPU max alignment is 16 but the
plugin requires 32 bytes alignment for the AVX2 path (that would never
be chosen on the CPU).

See #2074
2022-01-28 11:49:06 +01: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
8844c15d4d audiomixer: remove the empty buffer
We don't need the preallocated empty buffer. When we need to produce
samples, simply write to the output buffer.
2022-01-12 11:59:36 +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
2ed62f53d9 spa: allocate ports dynamically
So that we don't need to allocate large memory blocks that are mostly
unused.

See #1840
2022-01-01 17:41:27 +01:00
Wim Taymans
c8c4923fcb spa: use log topics 2021-10-13 10:48:23 +02:00
Wim Taymans
19a3bf2100 spa: handle last_port correctly
last_port is always 1 more than the highest valid port number.
2021-09-14 21:06:21 +02: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
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
73f50bb964 improve debug 2021-03-29 11:41:06 +02:00
Wim Taymans
cb7bfdf98a sprinkly SPA_LIKELY/UNLIKELY around 2020-03-16 12:52:28 +01:00
Wim Taymans
852ac043d3 Use the DSP format for dsp formats
Use the DSP media subtype to describe DSP formats. DSP formats
don't include the rate, channels and channel position in the
format and must use the rate and duration from the position io. This
makes it possible to later change the samplerate dynamically without
having to renegotiate the graph.

The same goes for the video DSP format, which uses the io_video_size
from the io_position to get the size/stride. Set this up in the node
based on the defaults from the context.

Make it possible to define defaults in the daemon config file, such
as samplerate, quantum, video size and framerate. This is stored in
the context and used for the DSP formats.
2020-01-09 15:18:59 +01:00
Wim Taymans
f391353c7f Make interface types a string
This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.
2019-12-19 13:36:04 +01:00
Wim Taymans
9ffec214b8 fix includes 2019-10-25 15:01:02 +02:00
Wim Taymans
af73585948 Increase max buffer size 2019-10-24 15:26:59 +02:00
Wim Taymans
7798cf7364 core: improve alignment
Use the CPU alignment to align memory of allocated buffers. This makes
it more likely that all CPU optimizations can be done.
2019-10-17 09:34:27 +02:00
Wim Taymans
c8ffcaaefe plugins: just check the data pointer
We don't need to look at the data type, we just just be happy when
the data pointer is filled in.
2019-10-16 12:23:42 +02:00
Wim Taymans
0ecbe4844e mixer: Move floatmix to the audio mixer plugin
Move floatmix to the audiomixer plugin and change the name to
AUDIO_MIXER_DSP.
Add runtime selectable sse and sse2 optimizations.
Load the port mixer plugin dynamically based on the factory_name.
Add some more debug
2019-10-03 16:20:12 +02:00
Renamed from src/pipewire/mix/floatmix.c (Browse further)