Commit graph

12406 commits

Author SHA1 Message Date
Arun Raghavan 1b6a94db36 doc: Add more details in the Overview section
Cover basic concepts that might be useful while going to subsequent
sections. We might want to split this off into a subpage if it gets any
longer.
2024-04-25 13:04:54 -04:00
Wim Taymans 9844aed31b impl-node: avoid bitfield races
Move the bits that are used in the realtime thread away from the bits
from the main thread to avoid bitfield races. Move some fields in rt
structs to make it explicit that they are only to be modified from the
realtime threads.
2024-04-25 16:18:03 +02:00
Wim Taymans 6fdf09e83e impl-node: remove redundant variable 2024-04-25 15:58:34 +02:00
Wim Taymans 9bb5780cc2 meta: add explicit sync metadata and data type
Change the GenericFd data type to SyncObj. It's probably better to
explicitly state the data type than to make something generic. Otherwise
we would need to transfer the specific fd type somewhere else and there
is no room for that in the buffer and the the metadata is not a good idea
either because it can be modified and corrupted at runtime.

Add the SyncTimeline metadata. This contains 2 points on two timelines
(SyncObj datas in the buffer). The buffer can be accessed when the
acquire_point is signaled on the timeline and when the buffer
can be released, the release_point on the timeline should be signaled.
2024-04-25 09:55:19 +02:00
Wim Taymans 31de44f679 client-node: simplify some things
We don't need to get the supprt just to get the logger.
2024-04-25 09:25:51 +02:00
Wim Taymans 14badae669 context: delay starting the loop until acquired
This should be fine because it's not possible to get to the data-loop
without doing acquire.

The main purpose is to make it possible first for modules to be loaded
before the first thread is started.
2024-04-25 09:24:58 +02:00
Wim Taymans ce47967be7 context: use acquire logic to fill data-loop in support
Each time someone asks for the support, acquire a new data loop and fill
it in the support.

Tweaks things a little so that acquire can be called with NULL dict, in
which case it will always use the first data loop. To be moved and
spread around loops one needs to explicitly pass a node.loop.name or
node.loop.class around.

This ensures that loading a plugin from the adapters and spa plugin
loaders always get the same loop when nothing or a node.loop.name is
given.

It doesn't quite work when a node.loop.class is given because then the loop
could be different between spa node and pipewire node. To fix this, we
need to improve the node loader code to make sure the same loop is used
everywhere.
2024-04-25 09:24:58 +02:00
Wim Taymans 1255d88969 context: handle NULL data loops
It's possible that the data loop failed to initialize and we should try
to avoid segfaulting on that.
2024-04-25 09:24:58 +02:00
Barnabás Pőcze 6a26e6dd3f treewide: fix some format string issues
Use the proper specifier, and cast to a known type where the type
is not guaranteed by any standard.

See #3975
2024-04-25 07:24:10 +00:00
Wim Taymans bdca7cb1a0 conf: warn when match actions are missing 2024-04-24 12:32:40 +02:00
Barnabás Pőcze 8b35b00d82 meson.build: add -Werror=incompatible-pointer-types 2024-04-23 14:49:34 +02:00
Stefan Ursella 65e8bec8dd module-protocol-simple: handle 'node.name' property 2024-04-23 11:11:30 +00:00
Pauli Virtanen 29614a2c46 doc: fix workaround for old doxygen versions
Fix workaround for old doxygen versions, and put a version requirement
for Doxygen.
2024-04-23 10:59:24 +00:00
Wim Taymans 8633729a15 context: only use FNM_EXTMATCH when defined
alpine does not seen to have this.
2024-04-23 12:57:00 +02:00
Wim Taymans 2eb9a7543a thread: use pthread_setaffinity_np
The attribute version does not seem to be supported on alpine.
2024-04-23 12:12:33 +02:00
Wim Taymans 20b52d2082 keys: add and use some loop keys 2024-04-23 11:49:12 +02:00
Wim Taymans 0e13d088e7 module-ffado: only start after ports are configured
Don't start yet when the ports are pending configuration.

See #3968
2024-04-22 17:43:04 +02:00
Wim Taymans 64695a8611 stream: add functions to get the assigned data loop 2024-04-22 16:32:03 +02:00
Wim Taymans c3d4abd7f1 modules: use acquire/release loop
Expose the acquire_loop/release_loop functions and use them in the
modules.

Make sure the nodes created from the module use the same data loop as
the module. We need to ensure this because otherwise, the nodes might
be scheduled on different data loops and the invoke or timer logic will
fail.
2024-04-22 16:19:02 +02:00
Wim Taymans c12cf748b6 loop: move the loop name to pw_loop
That way, all loops have a name and we can move nodes to specific loops
even if they are not a data loop.
2024-04-22 15:18:26 +02:00
Wim Taymans fbafaff31b context: reuse logic for pw_context_get_data_loop
Use the same logic for _get_data_loop() as _acquire_loop().
2024-04-22 11:16:53 +02:00
Wim Taymans 8459f6d25c data-loop: add functions to get name and class
This can be used to force nodes in the same class or data-loop.
2024-04-22 11:00:22 +02:00
Wim Taymans 4f352ca46b context: fill basic properties early
So that we can use them in match rules, such as the application.name
etc.
2024-04-22 10:48:23 +02:00
Wim Taymans 8dce124720 impl-port: only go through mixer for IO
Since we don't follow updates of the params on the mixer but only on the
port, we might get out of sync and fail to negotiate.

Going through the mixers for everything needs some more work.

Fixes #3971
2024-04-22 10:01:39 +02:00
Pauli Virtanen ac95f796bf combine-stream: fix latency-compensate with resample.disabled=true
When resample.disabled=true, which is now the default, Format has zero
rate, so latency buffers get zero size. The rate in this case is the
graph rate.

Fix by just using the delay in samples, as all streams must in any case
run at same rate for the combining to work.

Fixes: bff252ce60 ("combine-stream: actually make use of resample.disable")
2024-04-19 18:39:52 +03: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 a4bfdd7f82 context: add support for multiple data loops
Add config options to create and start multiple data loops, each with
their own priority and thread affinity if requested.

Make it possible to assign loop.classes to the data-loops. Use the
node.loop.class to find a data-loop for the node of the same class. Try
to evenly spread the nodes over the available matching loops.

With this, it is possible to separate the processing of the nodes
depending on the classes, like audio/video and improve concurency on
the server.

No attempt is done yet to move nodes between loops or to move
independent nodes to separate data loops.

Fixes #3969
2024-04-19 14:57:53 +02:00
Wim Taymans e85bb7194b profiler: remove unused data-loop 2024-04-19 12:16:39 +02:00
Wim Taymans a97a9b737c data-loop: support custom name and affinity 2024-04-18 17:46:22 +02:00
Wim Taymans 2d87310b60 thread: add support for thread affinity 2024-04-18 17:45:35 +02:00
Wim Taymans 696cd8977a context: remove redundant variable 2024-04-18 16:00:25 +02:00
Wim Taymans e1e0a886d5 stream: improve async handling
We can remove most of the special async handling in adapter, filter and
stream because this is now handled in the core.

Add a node.data-loop property to assign the node to a named data-loop.

Assign the non-rt stream and filter to the main loop. This means that
the node fd will be added to the main-loop and will be woken up directly
without having to wake up the RT thread and invoke the process callback
in the main-loop first. Because non-RT implies async, we can do all of
this like we do our rt processing because the output will only be used
in the next cycle.
2024-04-18 15:20:07 +02:00
Wim Taymans 34be6c76a6 v4l2: fix printf format 2024-04-18 12:48:09 +02:00
Ashok Sidipotu 9062182985 spa: v4l2: encode device id into a json array 2024-04-18 14:02:55 +05:30
Ashok Sidipotu 4d3d15aebe spa: libcamera: encode device ids into a json array 2024-04-18 14:02:54 +05:30
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 e8ac4e6a34 spa: add SPA_IO_AsyncBuffers
This structure has 2 io_buffers. Readers and writers operate on different
io_buffers to implement an asynchronous transfer.
2024-04-17 16:18:04 +02:00
Wim Taymans 84ed9c0fe9 impl-port: query all params through the mixer
Go through the mixers of the port to get the params.

This makes it possible to let the mixer decide on formats, buffers and
io areas.

Currently, the format is the same on all mixer input and output ports
and the buffers are shared on the output port but the idea is to make it
possible to have different formats and buffers per link.
2024-04-17 16:18:04 +02:00
Wim Taymans abb28e5255 impl-link: log error when activate fails 2024-04-17 16:18:04 +02:00
Wim Taymans 271f2d855d impl-port: implement port_enum_param on mixers
Implement the IO areas the default mixers support and proxy all other
queries to the peer port with the new node event.
2024-04-17 16:18:04 +02:00
Wim Taymans 67aafec8ab node: add an event to enumerate the peer port params
This can be used by nodes to filter or proxy the peer params.

Add test for new peer_enum_params event
2024-04-17 16:17:50 +02:00
Wim Taymans af6638251d impl-port: set position io on the mixer nodes
When adding the node, set the current node position IO. We don't need to
set the IO_Buffers because we did that when we set the mixer on the port.
2024-04-17 13:17:51 +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
Wim Taymans bf273690fd impl-node: add cycle to debug
Emit rt_start after incrementing the cycle so that it can use the new
cycle value.
2024-04-17 11:24:56 +02:00
Wim Taymans ec13e9148b impl-port: avoid doing work when the port is destroyed 2024-04-17 11:18:15 +02:00
Wim Taymans f8831f84d5 impl-port: refactor check_params
Make a new function to iterate the port params and update the flags etc.
Make sure we clear the cache first and reset the flags. This makes it
possible to call check_params later again.
2024-04-17 11:12:22 +02:00
Wim Taymans 4d01fa34fa impl-port: use 0 size when clearing IO 2024-04-17 11:07:03 +02:00
Wim Taymans 40b8ff187b stream: log a warning when media.class and direction mismatch
Fixes #2493
2024-04-17 09:53:54 +02:00
Jonas Holmberg 09088b376f rtp_stream: Use the log topic of the module
Set log topic to the topic of the module linked with stream instead of
logging with "default" topic.
2024-04-17 07:13:53 +00:00
Wim Taymans 24478b9128 module-loopback: only enable delay with valid rate and channels
Or else we can't calculate the required delay buffer size and we might
even end up with a double free.

Fixes #3748
2024-04-16 11:16:00 +02:00