Commit graph

1102 commits

Author SHA1 Message Date
Wim Taymans
060d0e1761 Revert "loop: don't call the hooks around blocking wait"
This reverts commit 46dfa69f26.

We do actually need to release the locks for now. The reason is that
pipewire core will at various points do a blocking invoke into the
thread-loop (which is the data-loop when using non-rt/async processing)
to synchronize state. Because these functions are called with the
thread-loop lock and from some other thread (like gstreamer) it causes
a deadlock because the thread-loop is locked and can't run and the
caller is waiting for the thread-loop to complete.

See #4472
2025-06-26 12:45:29 +02:00
Wim Taymans
88046b9f03 spa: add volume_ramp_scale enum type info
And link it to the SPA_PROP_volumeRampScale property
2025-06-13 11:53:42 +02:00
Wim Taymans
ecbd4f552c spa: make the wave, pattern and ditherType Int
Properties of type Id should have a type of the enum with the possible
values associated with them.

The other types that don't have a fixed enumeration but are usually
mapped to some constant/description with PropInfo should be Int.

Fixes !2399
2025-06-13 11:53:42 +02:00
Wim Taymans
46dfa69f26 loop: don't call the hooks around blocking wait
The blocking invoke function is not meant to be called with any of the
loop context locks acquired so that it can actually run the invoke call
while blocking. Make this (and other blocking risks) clear in the
documentation.

Because it is not supposed to be called with any of the locks, we should
also not try to call the hooks (that implement the unlock/lock).

Fixes #4472
2025-06-10 12:18:28 +02:00
Jonas Holmberg
fc9aa51619 pod: declare offset as unused in spa_pod_builder_bytes_end()
Fixes compiler warning:

/usr/include/spa-0.2/spa/pod/builder.h:357:69: error: unused parameter 'offset'
[-Werror=unused-parameter]
2025-05-29 09:08:40 +02:00
Wim Taymans
483b59a9d9 pod: add bytes start/append/end functions
Add functions to dynamically start and build a bytes pod.
2025-05-23 16:59:54 +02:00
Guido Günther
2d4af3ced5 spa: Add default: statements
This allows to use the library in projects that use `-Wswitch-default`
without any

 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wswitch-default"
 #pragma GCC diagnostic pop

This is useful as as the header is being pulled in via
pipewire/wireplumber headers into projects that might have this warning
enabled and would otherwise fail to build with -Werror.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-05-09 11:58:55 +02:00
Wim Taymans
f857a50734 ump: fix program change 2.0 to 1.0 conversion
The program change byte should not be shifted an extra bit, unlike all
the other messages.

Fixes #4664
2025-05-09 11:51:20 +02:00
Wim Taymans
3abda54d80 pod: use default value of filter
When using a filter, it makes more sense to use the default value
of the filter as a first attempt.

One case is in adapter when we try to find a passthrough format first. The
audioconverter suggests a default rate of the graph rate but the follower
filters this out for another unrelated default value and passthrough is not
possible (altough it would be because the default value of the filter is
in the supported follower range).

Fixes #4619
2025-05-09 11:49:08 +02:00
Wim Taymans
a9eba98e8e pod: handle builder overflows
When the builder is overflowed, we might get a NULL pod. This is a valid
situation that we need to handle because it can be used to get the
required builder buffer size.
2025-04-02 15:33:54 +02:00
Wim Taymans
4e63717e77 spa: fix device.profile key 2025-03-06 13:11:38 +01:00
Wim Taymans
54836736b0 pod: avoid use-after-free error because of reallocation
When the pod to filter is in the target builder memory and reallocation
is needed, make sure we refer to the filter in the reallocated memory
instead of the old freed memory.

Fixes #4445
2025-02-25 13:18:37 +01:00
Wim Taymans
c6de17c9b4 spa: improve introspection 2025-02-19 18:07:54 +01:00
Wim Taymans
fa15af376f context: avoid some scaling overflows
Make a macro to scale without overflows and use this in the context.
2025-01-24 16:23:01 +01:00
Wim Taymans
b97dd00f26 loop: add some more docs about loop_control
Add a gmainloop integration example.

See #4467
2025-01-20 11:48:07 +01:00
Pauli Virtanen
5f21ee8669 audioconvert: add delay_frac to spa_io_rate_match
Report the "fractional" part of the resampler delay in
spa_io_rate_match::delay_frac, in nanosamples (1/1e9 sample) at node
rate.

The delay values are best reported in units where it is clear what the
clock domain is, so report the value in fractional samples instead of
nanoseconds. Conversion to ns is also just dividision by the appropriate
rate.
2025-01-19 17:11:13 +02:00
Pauli Virtanen
1ec814977c logger: support logging local timestamps and other timestamp logs
In timestamps, support different clocks and local time as formats.

Local real time timestamps are useful when trying to correlate logs from
different sources.
2025-01-13 13:48:22 +00:00
Sanchayan Maity
13c026417b bluez5: Implement support for ASHA
ASHA is a Bluetooth specification for hearing aids.

For a high level overview of the ASHA Specification for BlueZ.
https://asymptotic.notion.site/ASHA-Spec-for-Bluez-61a46027fd46458d8235e14d6bedb2ce

The original specification in Android.
https://source.android.com/docs/core/connect/bluetooth/asha

Corresponding support in BlueZ.
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/profiles/audio/asha.c

This only implements handling of one side of a ASHA device
pair. Stereo support/handling of both "left" & "right" side
will follow later requiring work on clock synchronization
between the pair.
2025-01-09 14:51:50 +00:00
Sanchayan Maity
41d099a580 bluez5: Add G722 codec for ASHA
For documentation on ASHA, see
https://source.android.com/docs/core/connect/bluetooth/asha
2025-01-09 14:51:50 +00:00
Barnabás Pőcze
3752535171 hook: avoid macro expansion of the method names
Fixes #4491
2025-01-09 12:57:23 +01:00
Wim Taymans
49f48a5fda filter-graph: separate data and size for filter graph
Remove the chunk and add separate arrays with data and n_samples. This aligns
better with other methods and makes it possible to more easily reuse
arrays of pointers as input and output.
2025-01-07 10:38:32 +01:00
Wim Taymans
9f9e962dd6 filter-graph: pass spa_pod in get_props 2025-01-07 09:31:48 +01:00
Wim Taymans
c5ae456b9e filter-graph: pass dict to activate functions
This makes it possible to expand it more later.
2025-01-07 09:23:23 +01:00
Barnabás Pőcze
0d497a5f43 spa: debug: pod: print unsigned numbers as unsigned
Both `spa_rectangle` and `spa_fraction` store unsigned numbers,
so print them as unsigned, the same way it is already done in
`spa_debug_strbuf_format_value()`.
2025-01-05 21:33:03 +01:00
Pauli Virtanen
90f8b0e40b spa: acp: remove some strictly not necessary SplitPCM properties
Remove some api.alsa.split.* properties that the monitor script can
figure out itself.
2024-12-23 11:46:02 +02:00
Pauli Virtanen
dcccfcab7f spa: acp: get and emit UCM information for SplitPCM devices
When api.alsa.split-enable=true for ACP device, instruct UCM to not
use alsa-lib plugins for SplitPCM devices.

Grab the information from UCM for the intended channel remapping, and
add the splitting information to the nodes emitted.

Session manager can then look at that, and load nodes to do the channel
splitting.
2024-12-21 16:03:19 +02:00
Pauli Virtanen
61f9018e15 spa: fix spa_api_method_null macro NULL checks
What may be NULL in these methods is the pointer to the object
containing the spa_interface, not the interface pointer itself.

Fixes spa-acp-tool crashing with NULL deref in spa_i18n.
2024-12-07 18:30:25 +00:00
Wim Taymans
498aea661e spa: fix some param type info
Add an int array type and use this in the route properties.

Fixes #4441
2024-12-03 12:42:31 +01:00
Wim Taymans
3f0fe0032f node: add a clock flag to mark rate/duration inaccurate
Some clocks (v4l2) don't process exactly process buffers at the given
rate/duration so mark this in the clock flags.

We need to use the nsec field in the clock to derive ticks in pw-stream
in that case to get a good clock.
2024-11-26 17:02:02 +01:00
Wim Taymans
853c4783bc spa: inline some metadata functions 2024-11-26 12:46:58 +01:00
Wim Taymans
9fc33a6142 spa: add some more functions 2024-11-26 12:21:05 +01:00
Wim Taymans
31802d4994 add per type API defines 2024-11-26 11:58:51 +01:00
Wim Taymans
90b0e45037 make static inline -> SPA_API_IMPL
So that we can export the symbols as well.
2024-11-26 11:35:49 +01:00
Wim Taymans
84bd4b7ea9 spa: use static inline for interfaces instead of macro
It gives better typechecking and a path to make a library of functions.
2024-11-26 11:35:49 +01:00
Wim Taymans
f261b2f96f filter-chain: update channels from filter-graph
Add a filter-graph info structure with the number of inputs and outputs
in the graph definition.

Use the input/outputs to update the number of channels on the capture and
playback streams when not explicitly given. Also copy over the positions
when they match the other stream and were not explicitly specified.

Fixes #4404
2024-11-15 10:53:45 +01:00
Wim Taymans
2ad8904ac8 spa: update the UNPOSITIONED flag
When we can't parse valid positions, make sure the UNPOSITIONED flag is
set for raw audio info.
2024-11-14 11:06:11 +01:00
Wim Taymans
567b484386 filter-chain: move the filter-graph to plugins 2024-11-13 11:12:06 +01:00
Wim Taymans
9c49bffc22 keys: add lazy scheduling flags and docs 2024-11-06 12:57:48 +01:00
Wim Taymans
7906dc854a json: improve infinite checks
Avoid compiler errors like this:

 /usr/include/spa-0.2/spa/utils/json-core.h:417:25: error: comparing floating-point with '==' or '!=' is unsafe [-Werror=float-equal]
|   417 |                 if (val == INFINITY)
|       |                         ^~
2024-10-23 15:37:07 +02:00
Wim Taymans
da86026b7a latency: handle negative latency correctly
In our current world, it is possible to have a negative delay. This
means that the stream should be delayed to sync with other streams.

The pulse-server sets negative delay and the Latency message can hold
those negative values so make sure we handle them in the helper
functions as well.

Do the delay calculations in pw_stream and JACK with signed values to
correctly handle negative values. Clamp JACK latency range to 0 because
negative latency is not supported in JACK.

We should also probably make sure we never end up with negative
latency, mostly in ALSA when we set a Latency offset, but that is
another detail.
2024-10-23 10:47:58 +02:00
Wim Taymans
fa1ec61cf0 profiler: add followerClock block
Add a new followerClock block in the profiler info. This is only set
when the follower could be a driver and it contains the clock info used
for following the driver, mostly the rate difference and delay.

Dump this info in pw-profiler -J

Make sure we always set the info in the clock, especially also when we
are following.
2024-10-09 11:31:54 +02:00
Wim Taymans
5db02df08c spa: fix event pod type 2024-10-02 16:11:02 +02:00
Wim Taymans
0ca64277b3 spa: initialize all fields explicitly
Patch by Petar Popovic

Fixes #4325
2024-09-30 10:06:30 +02:00
Wim Taymans
4513aceaad spa: avoid C23 empty initializers in the headers
Patch by Petar Popovic to avoid using empty initializers in headers.

Fixes #4317
2024-09-25 10:58:11 +02:00
Wim Taymans
ed0556e34c jack: Improve transport BBT handling
The bar can start from 0 in JACK.

Add bar_start_tick and ticks_per_beat to the io_segment_bar so that we
can losslesly store the complete jack BBT values.

See #4314
2024-09-24 18:43:33 +02:00
Wim Taymans
4b9db9492e json-pod: add error checking version of json to pod
Add an error checking version of the json to pod converter and use that
in pw-cli to report about json parsing errors.
2024-09-23 10:12:56 +02:00
Wim Taymans
437be0af75 json-pod: return errors from spa_json_next()
Instead of silently ignoring the error and continuing.

See #4313
2024-09-23 09:36:31 +02:00
Wim Taymans
e3a7035e8f spa: make helper to init spa_audio_info_raw from dict
Make a function that can initialize raw audio info from a dict and fill
in the defaults. We can use this in many of the modules when the audio
format is parsed.
2024-09-18 15:48:27 +02:00
sunyuechi
8166b9c580 spa/support: implement RISCV V CPU detection 2024-09-18 10:40:48 +00:00
Wim Taymans
e2991f6398 json: add helper function to parse channel positions
Use the helper instead of duplicating the same code.

Also add some helpers to parse a json array of uint32_t

Move some functions to convert between type name and id.
2024-09-18 09:54:34 +02:00