Commit graph

11888 commits

Author SHA1 Message Date
Samuel Thibault
048285af7f spa plugins: Include Linux headers on Linux only 2024-03-31 12:38:27 +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
cc8b88cb51 alsa: add option to skip the busy check
Makes the card exposed even if some of the pcms are busy.

Fixes #3914
2024-03-30 18:27:06 +01:00
Wim Taymans
30f01b117e v4l2: set latency on port
Use the duration of one frame as the latency.

See #3910
2024-03-30 18:26:24 +01:00
Wim Taymans
3ddd171567 log: init topic_init function
Fixes #3916
2024-03-30 18:26:07 +01:00
Wim Taymans
201aaeef5d tools: print ??? when the quantum is unknown 2024-03-30 18:25:57 +01:00
Wim Taymans
7ae18c5098 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-30 18:25:37 +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
Wim Taymans
653be2dbde 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-30 18:25:07 +01:00
Wim Taymans
cc841a7667 acp: add more properties for the card
Use snd_ctl_card_info to set some more card properties such as the
alsa.id, alsa.mixer_name and alsa.components.

alsa.id is interesting because it is possible to use udev rules to set a
custom id, which is handy when you have two identical cards in the
system and want to assign unique ids to them.

See #3912
2024-03-30 18:24:29 +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
Steve Langasek
e995a20679 v4l2: unset _TIME_BITS in addition to _FILE_OFFSET_BITS
The v4l2 build unsets _FILE_OFFSET_BITS, which is not allowed when setting
_TIME_BITS=64.  Having verified that nothing in this module is sensitive to
64-bit time_t (none of the functions it intercepts handle time), we also
unset _TIME_BITS to allow this to build as before.

Signed-off-by: Steve Langasek <steve.langasek@canonical.com>
Reviewed-by: Dylan Aïssi <dylan.aissi@collabora.com>
2024-03-30 18:23:57 +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
010c9f1b93 audioconvert: also place resample output in rate_io
We can also place the estimated size that the resampler will produce in
the rate_io for output streams.

See #3750
2024-03-30 18:19:16 +01:00
Wim Taymans
13d4bb4b42 audioconvert: implement resample_out_len() 2024-03-30 18:19:16 +01:00
Pauli Virtanen
9419d458d1 doc: sync with master branch
Pick relevant doc updates.

doc: minor documentation improvements
doc: add options to change what /usr and /etc paths are shown
2024-03-17 14:44:47 +02:00
Arun Raghavan
e3fc41bf41 spa: alsa: Read ctl events instead of doing a global diff
This does a couple of things: first, we implement revents demangling,
which seems to be required (although hw: devices work fine without it).

The second is to actually read the ctl events so we can tell when
elements we care about have changed, instead of reading everything and
trying to do a diff.

The latter is also required from a correctness perspective, as otherwise
the ctl might keep triggering wakeups while the fd is ready to be read.
2024-03-15 12:20:38 -04:00
Wim Taymans
f2874ad1c2 1.0.4 2024-03-13 09:22:08 +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
6e710ea39b jack: set the output buffer size correctly
The output buffer size is always the current cycle buffer_size.
The size that is give by the JACK API is only used to restrict the
number of mixdown samples or midi offsets.

Fixes #3892
2024-03-12 17:44:46 +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
Wim Taymans
b3c7dda96a jack: fix multiple midi input ports
On the midi input ports, do the same trick as on the output ports:
first convert the midi to JACK and then copy the whole buffer to the
port specific storage.

This makes it possible to have a different midi buffer per port and
allow multiple threads to get the buffer concurrently.

Fixes #3901
2024-03-11 09:16:33 +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
David Turner
e5c810c0fa Add SOC-style jack names to HDMI audio paths
Currently the HDMI output paths have jack mixers named "HDMI/DP" and
with append-pcm-to-name=true.  However, most of the SOC audio drivers
are just named "HDMI" and don't add the ",pcm=N".  Add these alternate
jack names to the HDMI audio path files so that jack detection will work
on these SOCs.
2024-03-01 13:55:34 +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
Wim Taymans
b41e2391bd audioconvert: handle invalid ports better
Keep track of the valid ports and don't emit port info for
invalid ports. When a listener is added while the ports are being
created, it is possible that the ports are still NULL or invalid.
2024-03-01 13:54:29 +01:00
Wim Taymans
8942b74c18 audioconvert: handle port remove
The info is NULL when the port is removed, don't crash on that.
2024-03-01 13:53:56 +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
Wim Taymans
0b75a3bed7 jack: FORCE_RATE should just contain the rate 2024-03-01 13:53:15 +01:00
Wim Taymans
6242dab47c jack: set global_mix safely
Keep track of the active number of mixer ports and update the global mix
io in sync with the data thread because that is where we will check the
state of the global mix io.

This is mostly important for output ports. When removing all links from
an output port, we first will clear all the mixer io and then remove the
global mixer with client_node_port_set_mix_info(). If we don't clear the
io before that, the data thread will be using that buffers as they are
cleared.

See !1915
2024-03-01 13:52:31 +01:00