Commit graph

6391 commits

Author SHA1 Message Date
Wim Taymans
2379e83283 pipewire: document and improve -v option
Take the log level after we init pipewire to get the default level. Then
let the -v option increase it.

Fixes #3963
2024-04-15 15:39:50 +02:00
Pauli Virtanen
bff252ce60 combine-stream: actually make use of resample.disable
resample.disable was made to default to true, but copying it to stream
properties was forgotten so it didn't have any effect. Make sure to copy
it.

This will also prevent different input/output streams from negotiating
to different rates, which would result to broken audio since we are just
passing sample data through.
2024-04-14 18:58:45 +03:00
Pauli Virtanen
e1849a0650 combine-stream: check module arguments for syntax errors
Refuse to create module if the arguments were not properly parsed.
2024-04-14 16:24:16 +03:00
Wim Taymans
66ba147bfc filter: fix -UFASTPATH compilation 2024-04-10 18:28:18 +02:00
Wim Taymans
6aa690fa8d pipewire: add a -P option to set context properties
Add a -P (--properties) option to create the context with custom
properties. This can be used to control the modules that are loaded, for
example when they have conditions.
2024-04-10 18:13:01 +02:00
Wim Taymans
18ce166735 protocol-native: cleanup when starting a server fails 2024-04-10 18:12:14 +02:00
Wim Taymans
d672e8fbf2 stream: use the pw_impl_node implementation details
We can use the position/clock and driving variables from the
pw_impl_node instead of keeping another copy around.
2024-04-10 17:33:30 +02:00
Wim Taymans
06905cd53b impl-node: improve set_io some more
Make sure we first set up our own state before calling into the
implementation. That way, the implementation can look at the new state.
2024-04-10 17:22:34 +02:00
Wim Taymans
a683049986 impl-node: only become driving when we are a driver
We don't just need to check the clock and position clock id, we also
need to be able to become a driver before we can be driving.
2024-04-10 16:45:18 +02:00
Wim Taymans
39ca1bb9ed mem: MAPPABLE -> UNMAPPABLE
Change the flag from MAPPABLE to UNMAPPABLE to ease compatibility.

Older servers with newer client will not set the flag and so memory is
mappable for the client.
Newer server will set the flag but the client will ignore it and act
like before.
2024-04-10 13:11:54 +02:00
Wim Taymans
8115bf3eeb protocol-native: send debug to right topic 2024-04-10 13:11:17 +02:00
Robert Rosengren
95127d8a18 gst/src: fix crash when current_caps is NULL
gst_pad_get_current_caps may return NULL and passing that into
gst_caps_is_equal may result in fatal critical log due to the
"g_return_val_if_fail (GST_IS_CAPS (caps1)" check. Fix by checking for
NULL to avoid this.
2024-04-10 09:17:14 +00:00
Wim Taymans
c534acac46 spa: handle empty values better
Make sure the properties are not empty before trying to access them.
2024-04-10 11:08:40 +02:00
Wim Taymans
51c2b02e9e client-node: pass the right object to functions
These functions are not really used so not currently a problem.
2024-04-10 10:44:03 +02:00
Wim Taymans
7007ffcae1 impl-node: keep some state consistent
The target.id might be needed to find existing targets.
Update the properties after setting the initial state for the node, it
is a driver for itself and the properties can make it a driving node
when the driver property is set.
2024-04-10 10:26:00 +02:00
Wim Taymans
34c8322986 impl-node: count missed wakeups as xruns 2024-04-08 17:02:20 +02:00
Wim Taymans
8ce5211a64 impl-node: run recovery cycle immediately
There is no reason to use the fd to schedule process_node, we can call
it directly when we detect an underrun need to complete the cycle with
whatever data made it to the driver.

This avoids starting the graph while the process_node is running and
avoids some stuttering.

See #3937
2024-04-08 15:58:38 +02:00
Wim Taymans
cb716bcce7 impl-node: set_io on the port mixers 2024-04-05 15:55:12 +02:00
Wim Taymans
e9f4b55eb2 impl-node: set info.id as well
This is updated from the clock id a little later but we need it earlier
in the initialized event.
2024-04-05 15:53:13 +02:00
Wim Taymans
060052206f impl-node: add pw_impl_node_set_io()
Implement pw_impl_node_set_io() and do all the things that need to be
done in it, such as taking the clock.id, checking for driver etc.

We can then remove some code that tries to reimplement this, most
notably in the remote-node (where it was missing updates to the
target_rate and target_quantum and maybe related to #3845.
2024-04-05 13:16:46 +02:00
Wim Taymans
74de723ecc impl-node: improve node activation
Only activate the nodes when it was not-triggered, do this check with an
atomic compare-and-swap so that we only activate a node once.

We might be able to use this later to make sure that we resume the
untriggered peer nodes when we remove a node from the graph.
2024-04-04 22:01:44 +02:00
Wim Taymans
9cb4d820d5 impl-node: don't report xrun when pending <= 0
We might decrement too much but that would mean the driver was triggered
at some point and we don't really have an error.

Improve some debug
2024-04-04 22:01:01 +02:00
Wim Taymans
4db96d2197 impl-node: fix debug of do_move_nodes
Pass the old driver around so we can use it in debug. The new driver is
the one set in node->driver_node.
2024-04-04 21:00:50 +02:00
Wim Taymans
0633be3c12 node: add a cycle counter to the position
So that we can count the number of times the graph is scheduled.
2024-04-04 20:47:43 +02:00
Wim Taymans
f366167278 settings: remove link.min-buffers option again
The min should always be 1. We have other ways of bumping the number of
buffers to 2, like the ASYNC allocation flag which we can set if we are
also doing some async scheduling. We could make this an option later.

Otherwise, we would also allocate 2 buffers by default between the mixer
and the node, which is unnecessary.
2024-04-03 15:27:05 +02:00
Wim Taymans
dbedd09d42 settings: add link.min-buffers option
Add link.min-buffers option to set the minimum amount of buffers to
create for links. Set this by default to 2 because we really need two
now in case the sink xruns and does async mixing.

Make this an option because in low-memory cases and when xruns are not
expected, we can set this to 1.
2024-04-03 15:02:30 +02:00
Wim Taymans
5829276dbb client-node: fix array length debug 2024-04-03 13:29:27 +02:00
Wim Taymans
a01a33aa75 impl-node: improve xrun handling
To check if the driver was not completed, check the pending state
instead of the status. This is more correct and we can do this a little
smarter by swapping the current state with 0 atomically.

When we detect a non-zero pending state, wake up the driver node.
Because we atomically swapped 0, we are the only ones doing this and it
will make the node process whatever was in the input ports instead of
underrunning.

Running 2 apps outputting to a sink and pausing one will still play the
output of the other one, this way.

See #3509
Fixes #3937
2024-04-03 11:18:46 +02:00
Wim Taymans
208a343d9f module-ffado: add ffado.rtprio and ffado.realtime
Add two properties to control the realtime ffado thread and its
priority.

See #3558
2024-04-03 09:30:38 +02:00
Wim Taymans
986de92521 buffers: add support for mandatory metadata
Add a SPA_PARAM_BUFFERS_metaType in the Buffers object. This contains a
bitmask of the mandatory metadata items that should be included on a
buffer when using this Buffers param.

Make the buffer allocation logic skip over the Buffers params that
require unavailable metadata.

This can be used to, for example, enforce specific metadata to describe
extra buffer memory (such as the meaning of generic file descriptors).

One such use is the explicit sync, where an extra buffer data is needed
for the sync fd along with metadata that contains the sync_point.
2024-04-02 12:28:21 +02:00
Wim Taymans
a5c8100666 buffers: do some cleanups
Parse the metas right after we fixate the params and collec them in the
metas array. We don't have to loop twice and then we can simply pass the
prepared metas to alloc_buffers.

In case there are multiple Buffers params, take the first valid one and
ignore invalid ones.
2024-04-02 12:28:16 +02:00
Wim Taymans
f3fe20bdde buffer: add GenericFd memory type
Add a Generic fd type. These could be eventfd or timerfd, the meaning
can depend on extra metadata.
2024-04-02 12:28:09 +02:00
Wim Taymans
77f3b7f6e4 examples: set the MAPPABLE flag for MemFd 2024-04-02 12:28:01 +02:00
Wim Taymans
2f8740dee8 mem: add a PW_MEMBLOCK_FLAG_MAPPABLE flag and pass it around
This flags means that the fd can be mmaped without special handling. It
is the equivalent of the SPA_DATA_FLAG_MAPPABLE. Refuse to map memory
that is not mappable.

Make sure we make all allocated MemFd memory MAPPABLE by default. We can
then remove the stream and filter special handling for MemFd types and
just check the more generic MAPPABLE flag.

Make one exception when a client uploads MemFd buffer memory. We must
manually set the MAPPABLE flag for MemFd to make things backwards
compatible.
2024-04-02 12:27:58 +02:00
Wim Taymans
45984fef77 stream: only unmap data that was mapped and mappable. 2024-04-02 12:27:17 +02:00
Wim Taymans
0b42ec714d stream: handle node.name fallback better
If we don't have extra properties, set the node.name to the stream
name if it was not otherwise present.
2024-04-02 12:26:44 +02:00
Robert Mader
e2e8cf7944 gst/src: Avoid unnecessary renegotiations during streaming
Some clients like many camera apps, including Cheese or Snapshot,
trigger a lot of unnessecary renegotiations. While arguably that should
be solved on a Gstreamer level, we can help out by checking if the
preferred new caps are the same that are already in use and skip the
renegotiation in this case.

This allows several apps to e.g. take pictures without a slow and heavy
stream restart.
2024-03-31 11:03:13 +00:00
Robert Mader
594e3fa09f gst/src: Cleanups for src_negotiate()
Using `g_autoptr` and related modern helpers more often makes
the code smaller, easier to follow and maintain.
No behavior changes intended.
2024-03-31 11:03:13 +00:00
Pauli Virtanen
a9911f68a0 client-node: free port io memmap also if port gone
clear_port() clears all struct mix and removes the port, and can occur
before port io is set to NULL.  In this case the port memmaps are not
freed, and are leaked until client pool closes.

Fix by freeing the old io memmap when setting io to NULL, also when the
port was already cleared, so that the memmap lifecycle is the same as
that of the IO.
2024-03-29 20:39:13 +02:00
Robert Mader
cc0f7596d6 gst: Always use Choice-pod for modifiers
In order to follow the documentation more closely. Also restructure the
code a bit to make it easier to follow.

See also: e3227b2b5 (gst: simplify modifier extraction)

Fixes: f1b75fc6f (gst: Add support for DMA_DRM / explicit modifiers)
2024-03-28 18:45:13 +01:00
Wim Taymans
cddea858d9 context: add context.modules.allow-empty property
false by default, when true, no warning will be logged when the
context.modules in the config is empty. This can be useful when the
application wants to load all the modules itself.
2024-03-28 17:08:33 +01:00
Wim Taymans
d0c9d2f99d conf: only count modules, objects and exec when added
We don't actually do anything when the name, factory or path is NULL so
don't count this as an action.

Commenting out these keys is a usual way for commenting out complete
sections.
2024-03-28 17:00:56 +01:00
Wim Taymans
8351a17197 conf: add more error checks
Fail when something goes wrong when adding spa-libs instead of silently
ignoring it.
2024-03-28 17:00:18 +01:00
Wim Taymans
e3227b2b5d gst: simplify modifier extraction
spa_pod_get_values() handles both single values and Choice values and
turns the single value into a None choice.

Check that we have a None or Enum choice because we don't handle
anything else.

See !1952
2024-03-28 16:09:18 +01:00
Robert Mader
8848c7e792 gst: Re-enable handling of single long modifiers
A peer may announce support for a single modifier, in which case it may
not use a choice-pod. And while the documentation in `dma-buf.dox`
requires modifiers to always be announced as `SPA_CHOICE_Enum`, this has
been supported in the past - as well as matching Pipewire conventions.

Thus, in order to not break existing clients not crash, reintroduce
handling of modifiers as a single long.

Fixes: f1b75fc6f (gst: Add support for DMA_DRM / explicit modifiers)

Solution suggested by Barnabás Pőcze <pobrn@protonmail.com>
2024-03-28 15:09:34 +01:00
Wim Taymans
d682d8c5aa properties: rework properties
Handle allocation errors better, propagate the errors to the caller.

Avoid doing some useless work updating the dict, do this only after we
have done adding all the items when creating and copying.

Make update_string keep a temp array of updates and only apply the
updates when error checking was enabled and there was success. This
makes it possible to parse the JSON string only once.

Fix some of the lookup logic. We can just use spa_dict_lookup() and
spa_dict_lookup_item(), we don't need the index.
2024-03-28 12:37:07 +01:00
Wim Taymans
29ff3f196c filter-chain: debug SOFA error codes better 2024-03-28 09:27:04 +01:00
Wim Taymans
6d4f255ae9 filter-chain: report more parsing errors 2024-03-28 09:16:15 +01:00
Wim Taymans
a9fdc6a408 spa: improve JSON error reporting in spa-json-dump 2024-03-27 15:57:39 +01:00
Pauli Virtanen
04c5d3958b test: add tests validating all json conf files 2024-03-27 15:53:09 +01:00