Commit graph

7062 commits

Author SHA1 Message Date
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
Wim Taymans
6bdeeb5881 conf: unmap on errors 2024-03-27 15:50:25 +01:00
Wim Taymans
d4581755e6 spa: Improve JSON error reporting
Add struct spa_error_location that holds information about some parsing
context such as the line and column number, error and line fragment
with the error.

Make spa_json_get_error() fill in the spa_error_location instead. Add
some error codes to the error state and use this to add a parsing reason
to the location.

Add a debug function to log the error location in a nice way. Also
add a FILE based debug context to log to any FILE.

Replace pw_properties_check_string() with
pw_properties_update_string_checked() and add
pw_properties_new_string_checked(). The check string behaviour can still
be done by setting props to NULL but the main purpose is to be able to
avoid parsing the json file twice in the future.

When using the old pw_properties_update_string(), log a warning to the
log when we fail to parse the complete string.

Use the new checked functions and the debug functions to report about
parsing errors in the tools and conf parsing.

This gives errors like:

```
> pw-loopback --playback-props '{ foo =  [ f : g ] }'
error: syntax error in --playback-props: Invalid array separator
line:      1 | { foo =  [ f : g ] }
col:      14 |              ^
```
2024-03-27 15:42:29 +01:00
Wim Taymans
eb1376acc9 conf: log errors for json content errors
Log some errors when we get something we don't expect.
2024-03-26 09:46:07 +01:00
Pauli Virtanen
5987b0e65e daemon/conf: fix more JSON syntax 2024-03-25 21:42:26 +02:00
Pauli Virtanen
026d55df62 tools: check properties given by user for syntax errors
Check JSON passed in by user for syntax errors before processing it.
2024-03-25 21:42:26 +02:00
Pauli Virtanen
0da9255057 treewide: check for JSON parse errors
Check for JSON parse errors, and log error messages as appropriate.

It's mostly enough to do this where the input is parsed for the first
time, e.g. via pw_properties_new_string, as that already validates the
JSON syntax.
2024-03-25 21:42:26 +02:00
Pauli Virtanen
7ee8df39e8 properties: add pw_properties_check_string for checking parse errors
Add pw_properties_check_string which checks a props JSON string for
parse errors.
2024-03-25 21:42:26 +02:00
Pauli Virtanen
0a70395502 daemon/conf: fix bad JSON syntax 2024-03-25 19:03:13 +02:00
Jonas Holmberg
b868ba1f6f module-echo-cancel: Don't call _run() when inactive
Call _activate() in the aec spa plugin before both capture and sink
streams are started and call _deactivate() after both capture and sink
streams are stopped, to make sure _run() is not called while the spa
plugin is inactive.
2024-03-25 14:55:10 +00:00
Wim Taymans
8da8f90076 conf: add some warnings when keys are invalid and ignored 2024-03-25 14:28:43 +01:00
Wim Taymans
dfe18ca996 filter-chain: improve json parsing error reporting
Warn when an invalid key is parsed instead of silently ignoring it.
2024-03-25 14:19:45 +01:00
Wim Taymans
ac6011dfa5 module-rtp: save errno before doing pw_log_error
We can't assume the errno value won't be clobbered.
2024-03-25 13:21:42 +01:00
Wim Taymans
4ffd74ef46 module-rtp: handle state change errors better
Make a new function to set the rtp stream in the error state.

When we fail to start the stream, set the error state. Otherwise (like
when we try to use an invalid interface name) the socket create will
fail but the stream will still try to send data to the invalid socket.
2024-03-25 12:22:11 +01:00
Wim Taymans
6e7b893448 client-node: small cleanups 2024-03-22 16:48:29 +01:00
Wim Taymans
e2ad924cbb examples: add some more debug to video-play
Debug the latency param, debug the pts vs current time.
2024-03-22 11:31:05 +01:00
Wim Taymans
e66bdb016a tools: print ??? when the quantum is unknown 2024-03-21 09:51:12 +01:00
Wim Taymans
a3eca706ce module-ffado: add some more debug
Add some code to dyanmically switch period_size but it seems to keep
crashing ffado no matter what I try.
2024-03-19 15:46:46 +01:00
Wim Taymans
61dbad2cf3 module-ffado: make sure we close and open when suspend
Rework some things so that we can actually completely close and reopen
the driver when suspending. Leaving the device opened but not streaming
causes trouble when ffado-mixer changes the settings in between.

Do this by first doing a probe to get the ports and streams and then
link those to the actual buffers when we start streaming.

Follow the graph rate and quantum so that we open with the right
settings, this makes pw-metadata work on the quantum and rate. It
requires a driver reopen so it might be slower.

Try to handle some errors better.

See #3558
2024-03-19 13:20:29 +01:00
Wim Taymans
0e380de809 conf: improve matching rules a bit more
Handle "null", null, !null, "!null", !"null" and "!\"null\""
matches, copy some docs from wireplumber about the rules and
add some more cases.
2024-03-18 17:53:44 +01:00
Charlie Li
2821b05d0b module-raop-sink: explicitly include <openssl/evp.h>
As part of LibreSSL's cleanup of removed ENGINE support, <openssl/x509.h> is no longer included in <openssl/engine.h>. <openssl/evp.h> was transiently included in <openssl/x509.h>, compared to <openssl/rand.h> for OpenSSL.
2024-03-16 14:39:00 -04:00
Wim Taymans
2c0d73ab49 gst: handle latency in the pipewiresrc
Get the delay in the graph and subtract this from the cycle start time
to get the timestamp of the buffer.

Report this latency as well.

Fixes #30
2024-03-15 17:31:43 +01:00
Wim Taymans
1fe498560b gst: refactor some of the param handling
Clear the caps when the param is NULL.
2024-03-15 17:31:05 +01:00
Wim Taymans
2bd85e08cf gst: parse the audio rate from caps
Parse the audio rate from the caps and set this as the stream node.rate
property. This will try to switch the graph to this rate and avoids
resampling.

Rework some of the property handling.
2024-03-15 17:27:32 +01:00
Wim Taymans
9f74a31e9e include: install new header 2024-03-15 13:18:22 +01:00
Wim Taymans
9c072832f0 tests: cleanup correctly to avoid leaks 2024-03-15 13:08:58 +01:00
Wim Taymans
c2ba66bef6 protocol-native: clean up security context on unload 2024-03-15 13:00:30 +01:00
Wim Taymans
df50952f48 tests: add right include for close/unlink/pipe2 2024-03-15 12:39:20 +01:00
Wim Taymans
76ce2f77a4 test: handle running without a server
The security context test requires a running server, exit gracefully for
now when there is server running, like in the CI.
2024-03-15 12:25:30 +01:00
Wim Taymans
7e9e261fa6 conf: support property rules
Add pw_conf_section_update_props_rules() that will not only update the
properties of a section but wil also apply rules in section.rules and
match against the context properties.

Use this by default when using pw_context_conf_update_props().

Add a new method to get a string name of the VM type. Place the
cpu.vm.name in the context properties.

This makes it possible to deprecate the vm.overrides with something more
flexible based on rules. Update the conf files and docs to refect this.
2024-03-15 12:10:41 +01:00