Commit graph

6989 commits

Author SHA1 Message Date
Pauli Virtanen
e393e57a26 pulse-server: ensure positive stream delay in GET_PLAYBACK/RECORD_LATENCY
Pulseaudio protocol requires stream latency is uint64. Clamp the
Pipewire signed latency to the range, better than wrapping around.
2024-11-19 22:07:09 +02:00
Wim Taymans
a997627906 impl-node: save all previous timestamps on start
When the driver starts, save all previous node timestamps, not just the
previous signal time.

For async nodes, uses the previous timestamps in the profiler messages
so that we get stats with 1 cycle of delay instead of bogus values
because the node is still processing.

Fixes pw-top for async nodes.
2024-11-15 18:06:12 +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
Michael Olbrich
687075f2bd gst: handle interlace mode
If the peer announces an interlace mode then use it. Otherwise assume
that the video is not interlaced.

This also fixes a problem with caps negotiation:
If downstream reports caps with not fixated interlace mode, e.g.
"interlace-mode=(string){ progressive, interleaved, mixed }"
then without this, the caps handle_format_change() (in the pipewiresrc)
are not fixed and the source waits forever for the negotiation to
finish.
2024-11-14 17:18:28 +01:00
Wim Taymans
bb2d848bf6 impl-node: don't remove from graph when creating
When we were in the CREATING state, don't remove ourselves from the
graph because we were not added yet.
2024-11-14 15:56:57 +01:00
Wim Taymans
0833b19a75 module-vban: fill some default channel layouts
VBAN does not really transmit any channel layouts so make some
assumptions about the layout when not explicitly specified.
2024-11-14 11:07:05 +01:00
Wim Taymans
388f330700 module-vban: add stream.rules support
Make it possible to match the new VBAN streams on ip/port/name and media
properties and create a stream with custom properties.

See #4402
2024-11-14 09:59:12 +01:00
Wim Taymans
1a5514e5cf module-vban: create streams per stream_name
Always listen on the receive socket. Find the stream with the given
stream_name of the packet and create it if it doesn't exist.

Also take the sample-rate, channels and format from the packet
parameters instead of the config.

Fixes #4400
2024-11-13 16:47:34 +01:00
Wim Taymans
567b484386 filter-chain: move the filter-graph to plugins 2024-11-13 11:12:06 +01:00
Wim Taymans
2e157f7248 filter-chain: make filter-graph SPA plugins
Make SPA plugins from all the filter-graph plugins and use the plugin
loader to load them.

Because they are not in the standard plugin path in development, add
the module dir to the plugin path for now.
2024-11-13 10:20:54 +01:00
Wim Taymans
201455eecd filter-chain: don't link plugins to libpipewire
Reorganize some things so that we only link the pipewire module to
libpipewire. We don't need to link the filter-graph plugins to pipewire
anymore.
2024-11-12 16:32:54 +01:00
Wim Taymans
c3e668049b filter-chain: pass quantum-limit to plugins 2024-11-12 16:11:51 +01:00
Wim Taymans
13b8e3a75d filter-graph: Make dsp-ops and interface
Rename dsp-ops to audio-dsp and make it a SPA interface.

Pass the audio-dsp interface around with the support.
2024-11-12 15:54:28 +01:00
Wim Taymans
0a71911796 filter-chain: move the plugin to an audio-plugin
Make an interface of the audio plugins.
2024-11-12 12:51:15 +01:00
Wim Taymans
c8c89f7517 pulse: also set channels in the map
When converting a position to a channel-map, copy the number of channels
as well.

This broke with commit e2991f6398
2024-11-12 11:55:14 +01:00
Wim Taymans
22f7a1de28 filter-chain: move filter-chain to a spa_interface
Move the filter-chain code to a filter-graph SPA interface.

The idea is to make this more useful outside of the filter-chain.
2024-11-12 11:32:58 +01:00
Wim Taymans
d17c3fb72d filter-chain: move some biquad functions around
Make just 1 biquad function in dsp-ops.

Move the implementation prototypes to a separate header.
2024-11-11 17:59:10 +01:00
Wim Taymans
aad3d1eafa filter-chain: improve biquad run a little
We only need to copy source to dest on the first run.
2024-11-11 16:41:17 +01:00
Wim Taymans
02edfba21a filter-chain: don't let plugins depend on pipewire, just spa 2024-11-11 16:36:09 +01:00
Wim Taymans
44340fde05 module-rtp: allocate receive buffer based on MTU
Use the MTU to allocate the receive buffer instead of using a hardcoded
size.

Fixes #4394
2024-11-11 12:03:32 +01:00
Wim Taymans
a53bc035c0 module-rtp: calculate payload_size based on MTU
The actual payload size depends on the MTU but should not include the
IP/UDP and RTP headers.

Fixes #4396
2024-11-11 11:49:20 +01:00
Wim Taymans
bebad7888f gst: take the thread lock before calling pw_stream functions 2024-11-08 12:22:35 +01:00
Wim Taymans
1661f15b9c filter-chain: pass dict in plugin load function
So that we can pass some more properties around and remove the
quantum_limit hardcoded value.
2024-11-07 16:40:38 +01:00
George Kiagiadakis
c7854e1da4 filter-chain: move dsp_ops pointers to dynamically allocated memory
Make a plugin structure that is dynamically allocated for each plugin
and pass it around to the descriptor instance structures, so that they
all have access to dsp_ops without sharing a static pointer.

The problem with the static pointer is that the dsp_ops structure is
actually allocated in module-filter-chain's instance structure,
so it always points to the instance of the last filter-chain that was
loaded in the process. When this is unloaded, the other filter-chains
crash.
2024-11-07 15:15:03 +00:00
Wim Taymans
f7e97ab157 examples: update the examples with new lazy scheduling flags
The src can listen to RequestProcess commands and so gets the
node.supports-request = 1 property.

The play-pull example can both be a driver that listens to
RequestProcess or a lazy driver so set this in properties as well.
We can now remove the priority.driver property because automatic
priority selection will make us a driver or not.

With this change, video-src to video-play-pull will use lazy scheduling
with play-pull as the driver. video-play-pull to v4l2src will use
normal scheduling and video-src to video-play will also use normal
scheduling.
2024-11-06 12:57:48 +01:00
Wim Taymans
7abf11210d stream: expose the lazy flag with pw_stream_is_lazy()
Together with the is_driver() status, this can be used to check if the
stream is using lazy scheduling or not.
2024-11-06 12:57:48 +01:00
Wim Taymans
f16f074725 context: set lazy scheduling flags in clock
Collect the request scheduling flags and when there is a lazy driver,
set the lazy scheduling flag in its clock. This means that the driver
can expect RequestProcess commands to start the scheduling.

Pass the lazy scheduling clock flag to the node.

Make sure lazy scheduling driver have a higher priority than their
request drivers.
2024-11-06 12:57:48 +01:00
Wim Taymans
9c49bffc22 keys: add lazy scheduling flags and docs 2024-11-06 12:57:48 +01:00
Wim Taymans
ae0dd9195a modules: add ratelimit to xrun warnings in jack-tunnel
Take the current cycle times early and in all cases. We can use this to
get the current frame time for debugging purposes instead of the more
heavy jack_frame_time().

Rate limit the xrun warnings.
2024-11-06 12:29:21 +01:00
Robert Mader
2ab11d0f6c filter-chain: Fix build error without FFTW
And some style changes while on it.

Fixes: c67232718 ("filter-chain: move fft mem function to dsp_ops")
2024-11-05 18:25:21 +01:00
Wim Taymans
c672327181 filter-chain: move fft mem function to dsp_ops
So that we can have different versions per FFT.

One possible optimization would be to split the complex number in
separate real and imag arrays. This would speed up the multiply
operations.
2024-11-05 16:12:28 +01:00
Wim Taymans
79baeb8d18 modules: handle stream trigger errors
When we get a process callback from the capture stream but we can't
trigger the playback stream, simply consume the buffers from the capture
stream.

This can happen when the playback stream is not ready yet, for example.
If we don't consume the buffers that are ready, the converter might run
out of buffers and complain.
2024-11-05 15:59:01 +01:00
Wim Taymans
bc57b9ec86 impl-node: return a result from pw_impl_node_trigger()
Return 0 when the peer was not triggered, 1 when it was triggered and
an error when there was an error.
2024-11-05 15:53:12 +01:00
George Kiagiadakis
f12d37a421 pw-dot: fix information on the link labels 2024-11-05 12:09:43 +02:00
Niklas Carlsson
08af555e90 filter-chain: use Q value for biquad shelving filters
The current implementation uses the slope variable S to define the
filter slope. Setting S = 1 results in a constant Q value of
sqrt(2)/2, or 0.7071, which is a good default value.

However, calculating alpha from the Q value instead, as done in
RBJ's cookbook [1], the filter shape can be changed which might
be desired for certain applications and provides flexibility.

Since the current implementation always defaulted to using S = 1,
make sure that configurations missing Q uses the same slope value.

[1] = https://www.w3.org/TR/audio-eq-cookbook/
2024-11-04 16:54:55 +00:00
Pauli Virtanen
0d80a13771 modules: support config overrides for access & protocol-native
These modules are loaded in default config, but to configure sockets and
their permissions, the args need to be overridden.
2024-11-04 16:50:30 +00:00
Pauli Virtanen
5e8a7f434b doc: suggest fragment file name in example configs 2024-11-04 16:50:30 +00:00
Wim Taymans
9ed57c1dba impl-node: improve property parsing
Use pw_properties_get_uint32() and friends to parse properties and have
a fallback when the property is not there.
2024-11-04 16:52:09 +01:00
Niklas Carlsson
18148e7add filter-chain: fix unmap indexing for LV2 plugins
The index returned to the LV2 plugin starts from 1, but the array
index starts from 0.
2024-10-31 13:07:04 +01:00
Pauli Virtanen
8d019c5689 pulse-server: more specific error message when too many connections
This appears to be encountered often enough so a clearer message is
maybe useful.
2024-10-30 19:55:39 +02:00
Wim Taymans
3f41b93aa5 filter-chain: fix cmuladd
We need to add the result to src and store in dst. Also use the right
len in C fallback.
2024-10-29 11:55:03 +01:00
Pauli Virtanen
7f885a2e94 proxy: invalidate proxy id when removed from map
Client-side bugs calling methods on destroyed proxies like

    pw_proxy_ref(p);
    pw_proxy_destroy(p);
    ...
    wait for server to ack the remove
    ...
    pw_core_destroy(p->core, p); /* p already removed & destroyed */

should not send messages with the stale proxy id to server.

Set id to SPA_ID_INVALID when removing a proxy from the id map, so that
such client bugs only result to ENOENT.
2024-10-24 13:46:09 +00:00
Wim Taymans
24e1603f81 filter-chain: improve debug
So that it matches the instantiate debug line.
2024-10-24 11:04:15 +02:00
Wim Taymans
66942e5654 filter-chain: add example upmix filter
Add an example filter of PSD upmixing, using filters, convolver and
delay to simulate the upmixing logic in audioconvert.
2024-10-24 10:57:54 +02:00
Wim Taymans
42b994204d filter-chain: first create instances and then link port
First make instances of all the plugins and then try to link them up.

Otherwise, depending on the order the plugins are defined in the config,
a link will try to create port data and set it on the instance, which is
still NULL and we crash.
2024-10-24 10:55:50 +02:00
Wim Taymans
7be69f38d8 filter-chain: keep port data per instance
We can't share the memory between ports of different instances...
2024-10-24 10:47:32 +02:00
Jonas Holmberg
6223715918 module-rtp: Fix rtp timestamps
Because of operator precedence the timestamps where set to 0 if
set_timestamp was 0.
2024-10-23 16:12:55 +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
9243ed0cbd pulse-server: add condition support in pulse.cmd
So that a config override can disable the execution of the command by
setting the property to false in the pulse.properties config override.

Expose some conf.c method for this purpose.
2024-10-23 09:08:50 +02:00
Ola Fornander
12c8cdf69b gst: deviceprovider: fix memory leak in do_add_nodes
Use `g_autoptr()` to free the new_devices GList that is allocated in
do_add_nodes.
2024-10-22 21:53:57 +00:00