Commit graph

1018 commits

Author SHA1 Message Date
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
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
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
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
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
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
Robert Mader
bd5cc52c5c libcamera: add camera rotation property on nodes
Like the location, the orientation is a static property of libcamera
devices. While the rotation is already exposed as buffer transform,
knowing the property can be handy for applications in various ways.

See also: cd8ac5c1a ("libcamera: add camera location property on nodes")
2024-03-31 13:24:19 +02:00
Wim Taymans
66b8cd3e32 json: fix SPA_JSON_STATE
It should copy the state as well or else parsing will fail.
2024-03-28 09:14:18 +01:00
Pauli Virtanen
27ccf32030 spa: fix spelling 2024-03-27 18:42:31 +02:00
Pauli Virtanen
3e99a0e839 spa: deal with non-null terminated strings in spa_error_location
Add len field to indicate number of valid characters after location.
2024-03-27 18:36:06 +02:00
Wim Taymans
a0af514581 context: make error line debug a little better
Make a line to the ^ so that it is more visible. Spell out column
completely. Make the sizes a little smaller to avoid awkward gaps.
2024-03-27 16:23:38 +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
c954567021 spa-json: return value from spa_json_next()
So that we can check for errors or successful EOF.
2024-03-26 09:42:08 +01:00
Wim Taymans
1078df5212 spa-json: also check for len <= to avoid compiler warning 2024-03-26 09:41:02 +01:00
Pauli Virtanen
3775e4e624 spa: json: check object key-value pair parity during parsing
Check each object key is associated with value.  Disallow object or
array valued keys.

Add flag tracking whether the parser is at global top-level or not, as
there we may either be in object context or in a single-value context.

Save depth=0 array flag bit in state, so that spa_json_next preserves
its complete state across calls. The higher-depth flag bits can be in
temporary stack as they are not needed across calls.
2024-03-25 20:49:25 +02:00
Pauli Virtanen
921c8b99db spa: json: allow only ascii in bare values
Control characters probably are an error. We also are not validating any
utf8 here, so disallow bare utf8 too --- one likely should use strings
for such content anyway as spaces are not allowed otherwise.
2024-03-25 20:49:25 +02:00
Pauli Virtanen
11e20ef7a8 spa: json: \x7f is allowed unquoted in JSON 2024-03-25 20:49:25 +02:00
Pauli Virtanen
f45d89b75b spa: json: propagate parse error in spa_json_container_len
Successful return is always >= 2 since it includes {} or [], so use 0 to
indicate error.

Since there's existing code that doesn't check the return value, it's
better to use 0 for errors as it'll likely to just lead to producing an
empty string if the value is not checked.
2024-03-25 20:49:25 +02:00
Pauli Virtanen
31e5823010 spa: json: more parsing errors & add spa_json_get_error
Disallow = and : as bare items in [] containers, as that likely is
"[ { foo = bar } ]" mistyped as "[ foo = bar ]".

Disallow nesting errors, eg. "[ foo bar" or "[ foo bar }".

Fix handling of ", \ and # in bare strings.

Fix ignoring trailing comments.

Add a fixed-size stack (128 levels) to the tokenizer, so that it can
check these at levels below its depth.

When the tokenizer encounters an error, make it and its parents enter
error state where no further input will be processed. This allows caller
to check for parse errors later as convenient.

The error state can be queried using spa_json_get_error, which also
looks up the error line/column position.
2024-03-25 20:49:25 +02:00
Pauli Virtanen
41d7762f8b spa: json: fix string function usage in spa_json_parse_float/int
spa_json_parse_float/int receive non nul-terminated string, so calling
string functions assuming nul-termination is invalid.

Fix by copying data to a buffer before doing parsing.
2024-03-25 19:22:57 +02:00
Wim Taymans
58d626fec8 log: init topic_init function
Fixes #3916
2024-03-21 17:28:50 +01:00
Wim Taymans
832f7f5ba5 spa: a quick fix for compiling with -Werror=shadow
spa_exchange() is used in spa_clear_ptr() and spa_clear_fd() which
already use the _old_value variable. So make it use a slightly different
local variable name to avoid shadow warnings.

Fixes #3915
2024-03-20 10:06:44 +01:00
Wim Taymans
c52c56621d utils: use memmove when src and dst can overlap
spa_json_parse_stringn() can be used when the strings source and
destination are overlapping so use memmove instead of strncpy to
avoid corruption of the strings.
2024-03-18 16:32: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
Wim Taymans
ccf899a709 profiler: add transport state in the profile block
Add transport state to the profiler clock info and show this in
pw-top as t and T states.

Update the docs some more.
2024-02-29 14:07:08 +01:00
Wim Taymans
858d4e9e1c buffer: add MAPPABLE data flag
Add a MAPPABLE data flag that hints that the fd in the data is mappable
with a simple mmap/munmap. Normally, DmaBuf is not mappable like that
unless explicitly indicated with this flag.

Set the MAPPABLE flag on the DmaBuf from v4l2 and libcamera fd.

When asked, mmap the buffer memory in all cases when the MAPPABLE
flag is set.

This solves the case where v4l2 has exported DmaBuf and is streaming to
node A and then node B links but doesn't get automatically mmaped
memory.

Fixes #3840
2024-02-08 18:09:08 +01:00
Pauli Virtanen
61c585c8e6 bluez5: support Google's Opus A2DP vendor codec 2024-02-04 12:58:40 +02:00
columbarius
a1615fe6a3 vulkan: Add vulkan-blit-dsp-filter 2024-02-04 09:27:56 +00:00
columbarius
3e3a13c567 vulkan: Add vulkan-blit-filter 2024-02-04 09:27:56 +00:00
Pauli Virtanen
978dbff32f doc: fix some doxygen warnings 2024-01-29 08:50:32 +00:00
Wim Taymans
ad6e2ce480 param: clarify the internal latency 2024-01-29 09:41:11 +01:00
Pauli Virtanen
97db4a68a7 doc: explain clock/latency more
Update SPA_IO_Clock/Position documentation.

Explain some IOs are currently unused in PW.

Explain meaning of latency.
2024-01-29 08:36:15 +00:00
Pauli Virtanen
fe412784a4 bluez5: support LC3-SWB in HFP RFCOMM & add codec id for it
HFP 1.9 adds LC3 as a possible codec in addition to CVSD & mSBC.
E.g. Pixel Buds Pro latest firmware supports it.

Add the RFCOMM side and codec selection for it.
2024-01-25 08:43:45 +00:00
Wim Taymans
e7888d4ccc support: add resync.ms option to node.driver
Move some of the tracking code for the DLL to where it is used.

Add resync.ms (default 10) option at which we give up rate adjusting
and instead do a hard resync. This results in a jump in the position
of the graph clock.
2024-01-24 17:53:15 +01:00
Adam Marcus
79ee1eaff0 bluez5: add AAC-ELD codec 2024-01-22 14:04:16 +00:00
Thomas Weißschuh
4034e8f3c5 spa: mark constant parameters as such
The info parameter is never modified, communicate this to users.
This align format-utils.h with latency-utils.h.
2024-01-20 19:12:03 +01:00
Wim Taymans
b029a2ce05 pod: don't iterate 0 sized children
That will just create and endless loop and because the child has no
size, there is not really anything to iterate.
2024-01-16 16:34:37 +01:00
Demi Marie Obenour
0f533c6d64 docs: Multiple clarifications to documentation
See !1817
2024-01-12 11:55:28 +01:00
Jonas Holmberg
3b01205585 spa: Fix sign conversion in SPA_IS_ALIGNED
Fix the following compiler warning:
| In file included from /usr/include/spa-0.2/spa/utils/dict.h:14,
|                  from ../src/util_pipewire_objects.c:15:
| /usr/include/spa-0.2/spa/utils/defs.h: In function 'spa_ptr_inside_and_aligned':
| /usr/include/spa-0.2/spa/utils/defs.h:275:56: error: conversion to 'long unsigned int' from 'long int' may change the sign of the result [-Werror=sign-conversion]
|   275 | #define SPA_PTR_ALIGNMENT(p,align)      ((intptr_t)(p) & ((align)-1))
|       |                                                        ^
| /usr/include/spa-0.2/spa/utils/defs.h:276:42: note: in expansion of macro 'SPA_PTR_ALIGNMENT'
|   276 | #define SPA_IS_ALIGNED(p,align)         (SPA_PTR_ALIGNMENT(p,align) == 0)
|       |                                          ^~~~~~~~~~~~~~~~~
| /usr/include/spa-0.2/spa/utils/defs.h:308:13: note: in expansion of macro 'SPA_IS_ALIGNED'
|   308 |         if (SPA_IS_ALIGNED(p2, align)) {
|       |             ^~~~~~~~~~~~~~
2024-01-08 12:11:40 +01:00
Wim Taymans
a05a8eb8c6 spa: remove some references to unimplemented items
Fixes #3763
2024-01-05 10:07:58 +01:00
Pauli Virtanen
fc4dbcd033 spa: define symbols for log topic enumeration
Log topics are enumerated in an array of `struct spa_log_topic *`,
accessible via symbol `spa_log_topic_enum` pointing to a struct
spa_log_topic_enum in SPA shared libraries.

Add macros that use GCC section attribute to construct it with elf
magic.
2024-01-04 10:02:55 +00:00
Pauli Virtanen
d099ceaff1 spa: spa_strbuf_init should null-terminate 2024-01-04 10:02:55 +00:00
Demi Marie Obenour
0227a30bcf spa: Bounds-check pointers before dereferencing them
Add a new overflow-safe function to check if region p2 of size s2 fits
completely in p1 of size s1 and, if it does, return the amount of bytes
in p1 that come after the end of p2.  Use this to bounds check the pod
iterators while ensuring that the pointer is bounds checked before being
dereferenced.

The spa_pod*_next() functions can still create an out-of-bounds pointer,
but this will not be dereferenced.  Fixing this requires either
additional complexity in these functions or forbidding POD structs,
objects, and sequences that have a length that is not a multiple of 8
bytes.

Fixes: 92ac9a355f ("spa: add spa_ptrinside")
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-12-26 16:05:24 +00:00
Barnabás Pőcze
da7cf84f95 spa: utils: add SPA_CONCAT() macro 2023-12-26 16:03:29 +00:00
Wim Taymans
10d3c547d1 spa: add spa_ptrinside
Add a new overflow safe function to check if region p2 of size s2 fits
completely in p1 of size s1. Use this to bounds check the pod iterators.

Fixes #3727
2023-12-20 20:18:33 +01:00
Wim Taymans
283c215641 stream: make empty objects remove the PARAM
Make sure that NULL params don't cause -EINVAL but ignore them.

Don't add empty param objects. this makes it possible to clear all previous
params by setting an empty object.
2023-12-11 13:01:10 +01:00
Dorinda Bassey
f4a56ad45d Fix some warnings
added cleanup of unused variables and fix warning about missing initializers
to resolve build warnings in pipewire-rs

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-11-21 16:32:51 +00:00
Arun Raghavan
2871a65b1f alsa: Add a mechanism to bind ALSA controls as prop params
This adds an api.alsa.bind-ctls property to alsa-pcm sink and source
nodes, to bind a property to an ALSA PCM ctl. The property is an array
of ctl names that should be bound.

This can be handy, for example, to bind the Playback/Capture Rate
controls on a USB gadget, in order to track the PCM's state via a node
param.

This is currently wired to be read-only, but it should be easy enough to
make it writable.
2023-11-07 23:22:53 -05:00
Barnabás Pőcze
e4d1ab0c19 spa: debug: log: use SPA_CONTAINER_OF()
Use `SPA_CONTAINER_OF()` instead of direct casting as it is
more resilient against future changes that might reorder the
members in `struct spa_debug_log_ctx`.
2023-11-06 19:01:20 +01:00
Wim Taymans
dae0ccacfc spa: explicitly mention that volumes are linear
See #3623
2023-11-04 09:51:14 +01:00