Commit graph

6195 commits

Author SHA1 Message Date
Wim Taymans
a7a0e2072e conf: warn when match actions are missing 2024-04-29 16:17:34 +02:00
Stefan Ursella
0f0c9e8995 module-protocol-simple: handle 'node.name' property 2024-04-29 16:17:16 +02:00
Wim Taymans
976764514f module-ffado: only start after ports are configured
Don't start yet when the ports are pending configuration.

See #3968
2024-04-23 11:16:40 +02:00
Wim Taymans
594d255c5e context: fill basic properties early
So that we can use them in match rules, such as the application.name
etc.
2024-04-23 11:16:40 +02:00
Pauli Virtanen
cf646fb4dd combine-stream: fix latency-compensate with resample.disabled=true
When resample.disabled=true, which is now the default, Format has zero
rate, so latency buffers get zero size. The rate in this case is the
graph rate.

Fix by just using the delay in samples, as all streams must in any case
run at same rate for the combining to work.

Fixes: bff252ce60 ("combine-stream: actually make use of resample.disable")
2024-04-23 11:16:40 +02:00
Wim Taymans
a5727432c9 profiler: remove unused data-loop 2024-04-23 11:16:40 +02:00
Wim Taymans
aefe407d79 impl-port: avoid doing work when the port is destroyed 2024-04-23 11:16:40 +02:00
Wim Taymans
f65dd4e515 impl-port: use 0 size when clearing IO 2024-04-23 11:16:40 +02:00
Wim Taymans
edc4c856b7 stream: log a warning when media.class and direction mismatch
Fixes #2493
2024-04-23 11:16:40 +02:00
Wim Taymans
e9f0638a70 module-loopback: only enable delay with valid rate and channels
Or else we can't calculate the required delay buffer size and we might
even end up with a double free.

Fixes #3748
2024-04-23 11:16:36 +02:00
Pauli Virtanen
bf148d59cd 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-16 09:55:38 +02:00
Wim Taymans
b72ead1dea spa: handle empty values better
Make sure the properties are not empty before trying to access them.
2024-04-10 13:19:23 +02:00
Wim Taymans
28ab18ddd4 client-node: pass the right object to functions
These functions are not really used so not currently a problem.
2024-04-10 11:10:10 +02:00
Wim Taymans
822b8114b5 stream: only unmap data that was mapped and mappable. 2024-04-02 13:30:36 +02:00
Wim Taymans
ecb35b976f 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 13:30:20 +02:00
Pauli Virtanen
88db0a9103 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-31 12:50:54 +02:00
Wim Taymans
6279d79339 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-31 12:48:31 +02:00
Wim Taymans
8d0f738882 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-31 12:48:22 +02:00
Wim Taymans
5cb7d4c019 conf: add more error checks
Fail when something goes wrong when adding spa-libs instead of silently
ignoring it.
2024-03-31 12:48:15 +02:00
Jonas Holmberg
64cc53cc38 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-31 12:38:48 +02:00
Wim Taymans
3bab51ca73 conf: add some warnings when keys are invalid and ignored 2024-03-31 12:38:10 +02:00
Wim Taymans
cee9f740e4 filter-chain: improve json parsing error reporting
Warn when an invalid key is parsed instead of silently ignoring it.
2024-03-31 12:37:51 +02:00
Wim Taymans
dcc32c3be1 client-node: small cleanups 2024-03-30 18:27:23 +01:00
Wim Taymans
201aaeef5d tools: print ??? when the quantum is unknown 2024-03-30 18:25:57 +01:00
Wim Taymans
31c437b9d6 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-30 18:25:28 +01:00
Wim Taymans
85dd429858 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-30 18:25:22 +01:00
Charlie Li
99795cb8c1 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-30 18:24:09 +01:00
Wim Taymans
03b76b6755 gst: fall back to buffer time when no header
This at least sets some form of timestamp on the buffers.
2024-03-30 18:19:16 +01:00
Wim Taymans
e52a56bf68 tests: update unit test for added field 2024-03-30 18:19:16 +01:00
Wim Taymans
cb7ca883df stream: add time field to pw_buffer
For capture streams, place the time of the cycle when we received this
buffer in the new buffer time field.

Without this (and without timestamps in an optional header metadata)
it's impossible to determine when a buffer was created. With this field
and the pw_stream_get_time_n() and pw_stream_get_nsec() we can derive
the mapping to ticks and delay in the graph.
2024-03-30 18:19:16 +01:00
Wim Taymans
945a4e9336 stream: improve the timing info
Always copy the timing info when capturing, not only when there is a
buffer to dequeue.

We can update the rate_queued and rate_size with defaults when we don't
have rate matching. We can then also directly use the rate_size field
to update the buffer requested size.
2024-03-30 18:19:16 +01:00
Wim Taymans
1d365592c3 stream: update some docs 2024-03-30 18:19:16 +01:00
Wim Taymans
d0aca52681 stream: rename requested to size in pw_time
Now that both the expected input and output of the resampler is placed
in the rate_match, rename the 'requested' field in pw_time to 'size'
and update the docs.

See #3750
2024-03-30 18:19:16 +01:00
Wim Taymans
0ede521384 stream: add resample size to pw_time
Now that the resampler input size is set in the io_rate field when we
start we can add it to the pw_time struct as well.

This way we can know the required resampler input without having
to dequeue a buffer. This can be handy when the stream is a driver
and needs to know how much data to accumulate before starting the graph.

See #3750
2024-03-30 18:19:16 +01:00
Wim Taymans
9da78c4cd8 gst: only remove port once
The port has node_data set/cleared when it is added/removed to/from
the node. Make sure we only remove the port once to avoid a valgrind
error.
2024-03-12 17:44:56 +01:00
Wim Taymans
a1e59effee module-ffado: add more port properties
Mark control ports so that wireplumber does not attempt to link them.
Clear ports before making new ones, don't free NULL ports.
2024-03-12 17:44:41 +01:00
Wim Taymans
436bd37342 settings: add default.clock.quantum-floor property
Remove some of the hardcoded values (the absolute smallest buffer size,
independent on the sample rate) to a config option. Set it to the
default value of 4, like what it was before.

Change the hardcoded absolute lowest limit to 1 because anything else
does not make sense.

Enforce the quantum-floor when calculating the final graph quantum.

Fixes #3908
2024-03-12 17:44:25 +01:00
Wim Taymans
d801654836 module-ffado: disable pause on idle
Let the module run for a little longer until the session manager
suspends it.
2024-03-12 17:39:41 +01:00
Wim Taymans
863b3be343 audioconvert: add monitor.passthrough option
Add a monitor.passthrough option. This will pass all latency information
directly between the port and its monitor ports.

This is interesting when the adapter (and audioconvert) is used with a
null-audio-sink that simply forwards the data to a real sink/souce. In
that case, we want the sink/source latency to be passed unmodified.

Set the monitor.passthrough on the pulseaudio null-sink because
a passthrough virtual sink is the most likely use case for this.

Add some monitor.passthrough default config where it makes sense.

Fixes #3888
2024-03-12 17:39:33 +01:00
Wim Taymans
6d3790d794 module-ffado: copt link.group property 2024-03-12 17:39:11 +01:00
Wim Taymans
89d8e8b381 module-ffado: make the event buffer per port
Or else ports overwrite eachother.
2024-03-11 09:34:29 +01:00
Wim Taymans
383da7531c module-ffado: handle MIDI correctly
When the midi message does not fit in the current cycle, save it in a
buffer and send it in the next cycle.

Incomplete midi messages will be received in the next cycle and need to
be sent out at timestamp 0 of the cycle.

Detect dropped and incomplete messages and give a warning.

Try to close/open the ffado device when streaming_start() fails. This
seems to be the case after suspend/resume or a cable disconnect.
Unfortunately, ffado seems to be stuck in an unrecoverable state,
though, to make it really work...

Clean up port buffers when the filter is destroyed.
2024-03-11 09:34:19 +01:00
Wim Taymans
4e4de27cf6 module-ffado: implement MIDI send and receive 2024-03-11 09:34:05 +01:00
Wim Taymans
365181b8af module-ffado: various fixes to make things work
The FFADO source needs to be the driver and the sink the follower so
that captured data can flow to playback without delay.

Instead of starting a new thread for FFADO, use a timer and the data
loop to wait for FFADO. This is not so nice because we do blocking waits
on the data thread but then we can schedule the source and sink without
a context switch from FFADO. We use a timer so that we can set a timeout
period before starting the graph and catch xruns. The timer will be
restarted immediately when the graph completes and we can go back into
the FFADO wait.

FFADO Xrun should result in a new wait() call.

Handle channels better, use AUX for the channels when they don't match
the given positions.

Silence playback when we don't have a sink or sink data.

Stop and start FFADO when the sink/source pause/resume.

PIPEWIRE_CONFIG_NAME=client-rt.conf pw-cli -m load-module
libpipewire-module-ffado-driver '{ ffado.period-size=32 ffado.period-num=2 }
now gives 4.722ms latency measured with jack_iodelay, equal to JACK.

See #3558
2024-03-11 09:33:57 +01:00
Wim Taymans
4c75d4f660 stream: add pw_stream_get_nsec() to get current time
Make a method to get the current time to compare agains the pw_time-now
field. This is currently CLOCK_MONOTONIC but make this into a method
so that we can more easily change it later.
2024-03-11 09:25:48 +01:00
Barnabás Pőcze
c649f4a328 pw-top: only check terminal size in non-batch mode
If ncurses is not initialized, then the global `LINES` variable stays 0.
This will cause problems because there is an unconditional `if (y > LINES)`
check when printing the driven nodes for a given driver node, resulting
in only the first one being printed.

Commit 71653e04d2 ("pw-top: add 'batch-mode' and iterations known from top")
that introduced batch mode missed this one condition, so fix that
by only checking the for terminal overflow in non-batch mode as
it is done a couple lines above.

Fixes #3899
2024-03-08 18:22:28 +01:00
Antonio Larrosa
f3b20ae1e2 Specify "Audio" in gstreamer sink/src metadata to fix autodetect
gst-play uses autoaudiosink by default when playing audio, which
iterates over all sinks sorting them by rank. By default,
pipewiresink sets the rank to 0, but it can be overridden
by setting the GST_PLUGIN_FEATURE_RANK env. var. like this:

`GST_PLUGIN_FEATURE_RANK=pipewiresink:268 gst-play-1.0  /usr/share/sounds/alsa/test.wav`

But that doesn't work either because the autoaudiosink plugin also
filters the available options, testing for "Sink" and "Audio" to
appear in the classification metadata

(in the strstr comparison in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gst-plugins-good/gst/autodetect/gstautodetect.c?ref_type=heads#L220
klass is what's set by pipewire as classification,
self->type_klass is "Sink" and self->media_klass is "Audio")

Just adding the word Audio to the classification metadata fixes
this and allows pipewiresink to be selected by autoaudiosink.

I also set it in the source plugin since looking at the code,
autoaudiosrc works exactly the same.
2024-03-08 18:22:08 +01:00
Wim Taymans
4fba866676 gst: remove timeouts when autoconnect=false
When we disable autoconnect, disable the timeouts as well. Otherwise the
user has to connect the stream within the 30 second timeout or get a
failure. With autoconnect we can reasonably assume there is a problem
when the stream is not connected after 30 seconds.

Fixes #3884
2024-03-01 13:55:28 +01:00
George Kiagiadakis
71ae3df6f2 pw_context_parse_conf_section: use the conf argument instead of the context's conf
The conf argument was unused before, but it is correctly populated
using the context's conf in pw_context_new(), so the code behaves
the same effectively.

This allows parsing standard conf sections from other configuration
sources, as long as the sections are placed in a dictionary.
2024-03-01 13:53:44 +01:00
Wim Taymans
e62ab00f83 stream: FORCE_RATE should just contain the rate 2024-03-01 13:53:22 +01:00