Commit graph

12535 commits

Author SHA1 Message Date
Wim Taymans c963ca47c1 module-ffado: disable pause on idle
Let the module run for a little longer until the session manager
suspends it.
2024-03-11 16:55:35 +01:00
Wim Taymans ea524b158c 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-11 16:20:27 +01:00
Wim Taymans 10830ab9f8 module-ffado: copt link.group property 2024-03-11 13:22:20 +01:00
Pauli Virtanen da1a5568a1 doc: add options to change what /usr and /etc paths are shown
Add options to change the 'prefix' and 'sysconfdir' values shown in
documentation, e.g. on config file man pages.

Update CI to set them, so that its produced output doesn't show
/builds/pipewire/... on man pages
2024-03-10 22:25:42 +02:00
Pauli Virtanen e2a546006a doc: minor documentation improvements
Document a few properties more, and fix some wrong things.

Mark types of properties.
2024-03-10 19:08:41 +02:00
Wim Taymans 1e92ecea53 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-08 16:31:00 +01:00
Wim Taymans 37900ff765 module-ffado: make the event buffer per port
Or else ports overwrite eachother.
2024-03-08 15:24:33 +01:00
Wim Taymans fc0b638045 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-08 13:00:34 +01:00
Pauli Virtanen 7d0ca2d103 spa: node-driver: always put CLOCK_MONOTONIC values to clock->nsec
When timer is not using monotonic clock, apply clock offset to translate
the time values to the monotonic clock when putting them to spa_io_clock
nsec fields.

Get appropriate clock offset by smoothed filtering.  The parameters here
keep the offset jitter < 10ns or so.

As monotonic/boottime/realtime all contain adjtime(), there generally is
no drift in the offset here, so just averaging should be fine.

Also fix using wrong timer clock when freewheeling.
2024-03-07 20:04:54 +02:00
Barnabás Pőcze c12e9a745d 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-07 17:17:35 +00:00
Barnabás Pőcze cf984fcd4c spa: alsa: fix clang build
Variable declarations after a label are not allowed,
and clang does not accept them. Fix the build failure
by removing the variable.

Fixes b3fbd0e607 ("alsa-pcm: add_bind_ctl_param: add support for array")
2024-03-07 17:16:55 +00:00
Robert Mader 1a6bb994a5 gst: Fix sanitization of non-writable caps
`gst_caps_make_writable()` may create a copy which we have to keep
using afterwards. The return value was meant to be used for that,
but was promptly forgotten for the initial user.
Avoid such errors in the future by using an in-out parameter instead.

While on it, add a type check and remove a check for an impossible
condition.

Fixes: 8a271a87b ("gst: Sanitize caps before translating")
2024-03-07 17:16:18 +00:00
Antonio Larrosa 2df931483d 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-07 17:15:20 +00:00
Wim Taymans 60d68e0d66 module-ffado: implement MIDI send and receive 2024-03-07 18:11:01 +01:00
Wim Taymans f3d9b823bd 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-06 18:01:33 +01:00
Emil Svendsen b3fbd0e607 alsa-pcm: add_bind_ctl_param: add support for array
ALSA controls are represented as an array. So let's make it possible to
handle array's and bytes.
2024-03-06 08:44:13 +01:00
Emil Svendsen 96f35e15a0 alsa-pcm: bind_ctl: add better ctl name matching
For matching kctl without the numid you need to specify interface,
device, subdevice, name and index. So the current implementation can
only match kctls on IFACE_PCM, device 0, subdevice 0 and index 0.

Instead of adding all these matching parameters this commit fetches all
kctls attached to the audio card and match on the first occurred kctl
with matching name.

This should be sufficient for audio cards with unique kctl names. When
non unique names are needed, more kctl matching parameters needs to be
added.
2024-03-05 17:48:56 +00:00
Robert Mader 8a271a87b7 gst: Sanitize caps before translating
DMABuf caps without concrete formats and modifiers don't map well to the
Pipewire negotiation process.
Introduce a new gst_caps_sanitize() helper function, where such cases
can be handled.
2024-03-05 12:08:32 +01:00
Robert Mader f1b75fc6f8 gst: Add support for DMA_DRM / explicit modifiers
Gstreamer 1.24 added and largely switched to a new, modifier aware
DMABuf API. Unfortunately that breaks the existing DMABuf support in the
PW Gst element.

Add support for the new API.
2024-03-05 12:08:32 +01:00
Wim Taymans f2f60ee0ec jack-tunnel: convert JACK time to MONOTONIC
JACK current_msec can be in MONOTONIC_RAW or MONOTONIC, depending on how
JACK was compiled (but it's likely MONOTONIC_RAW). PipeWire requires the
nsec field to be in MONOTONIC so take some time snapshots from both
clocks and apply a translation.

Also make sure we only get the nsec time from streams that exist.

See #3886
2024-03-04 15:34:42 +01:00
Wim Taymans f4e391dd41 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-04 12:59:26 +01:00
Emil Svendsen 81d8ecf0dc alsa-pcm: snd_ctl_open: remove device suffix
ALSA controls can only be opened on the card itself and will fail when
trying to open controls on the ALSA device. The device name we get may
or may not include the device suffix. If no suffix is present the
default device is 0 that's why currently it works on most audio cards.
But all other devices above 0 needs the suffix [1].

[1]
Device 0: hw:cardname
Device 0: hw:cardname,0
Device 1: hw:cardname,1
Device 2: hw:cardname,2
Device X: hw:cardname,X
2024-03-04 09:45:37 +00:00
Dimitrios Katsaros c1eacce3fc alsa: Use hi-res timestamps in irq mode when available
We know in IRQ mode that any valid hi-res timestamp that the
driver privides will be before the wakeup event in pipewire.

This makes it so in IRQ mode we use better timestamping when possible,
which decreases jitter injected into the DLL, which in turn reduces
the amount of oscillations the resampler is exposed to.
2024-03-01 21:46:21 +01:00
David Turner 0cfe57f33d 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 09:33:55 +00:00
Wim Taymans 0f14cc3b13 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 10:29:18 +01:00
Wim Taymans 06f63f489a node: add node.sync-group and node.sync
node.sync-group can contain a list of strings. When a node in the graph
sets node.sync = true, it will be scheduled with all of the other nodes with
common node.sync-group strings. By default all nodes are placed in
group.sync.0 except the freewheel and dummy driver.

Use this to ensure that all nodes are grouped under the same driver
(that is not the freewheel and dummy driver) as soon as the transport is
started so that the transport is visible to all nodes from the same
sync-groups. We also don't deactive the sync-group anymore for the node,
even if the transport is stopped, to avoid driver changes and transport
jumps.

When the node that activated the sync/transport is destroyed, things are
restored to their original state. Note that this is different from JACK
where starting the transport outlives the application and always needs
to be explicitly stopped again. We can't really do this (by default) because
it leaves the graph in an unnatural state with all devices in sync.

The reason for the node.sync-group is that it is possible to still have N
different subgraphs with a separate transports by manually specifying
the node.sync-group.

It's also slightly different from the node.group, that is always active.
The sync-group is something you only want to enable in specific cases
because it groups drivers together and enables adaptive resampling etc.

It's also possible to place this option in the jack.conf file to
automatically sync all devices and apps as soon as a jack app is started.

Fixes #3850
2024-02-29 18:04:05 +01:00
Wim Taymans d063ab7322 node: use new node.transport property to start/stop transport
Instead of modifying the driver activation to start/stop the transport,
use a property on the node and let the server handle the change.
2024-02-29 17:45:28 +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 94d19f2673 jack: when leaving freewheel, set property to empty string
Setting it to NULL will remove it from the properties and will not
send the updated property to the server, keeping things freewheeling
forever.
2024-02-28 18:53:52 +01:00
Wim Taymans 66792c1e77 jack: handle freewheel property a little better
Don't just overwite the node.group property when changing the freewheel
thate but append the frewheel group and remove it again to preserve
the original node.group.
2024-02-28 16:39:03 +01:00
Wim Taymans cbffa9c568 node: add the current driver id to the node activation
See #3873
2024-02-28 11:42:09 +01:00
Wim Taymans a82e95c37d 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-02-28 11:29:01 +01:00
Wim Taymans d24a80c9d5 audioconvert: handle port remove
The info is NULL when the port is removed, don't crash on that.
2024-02-28 11:28:22 +01:00
George Kiagiadakis 0912201664 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-02-28 11:48:21 +02:00
Barnabás Pőcze 8cf5bbf658 pw-link: do argument check before sync 2024-02-27 08:32:56 +00:00
Barnabás Pőcze e362a66880 pw-link: do not leak memory 2024-02-27 08:32:56 +00:00
Barnabás Pőcze ca5a342e92 pw-link: use the regex_t objects in struct data 2024-02-27 08:32:56 +00:00
Barnabás Pőcze 431a201d6c pw-link: make mode a proper enum 2024-02-27 08:32:56 +00:00
Barnabás Pőcze 8947ba504e pw-link: use a simple boolean flag to control monitor mode
Monitoring does not interact with the normal modes of pw-link,
so separate it from them.
2024-02-27 08:32:56 +00:00
Barnabás Pőcze 241346d887 pw-link: use union for type specific data
This is safer than using a bare array of `uint32_t` with hard-coded indices.
2024-02-27 08:32:56 +00:00
Barnabás Pőcze 6160615726 pw-link: use proper enum for object types
Using an enum provides better debugging experience and
indicates the purpose better than a bare `uint32_t`.
2024-02-27 08:32:56 +00:00
Barnabás Pőcze 5218afc7e8 pw-link: pass false instead of NULL for bool parameter 2024-02-27 08:32:56 +00:00
Barnabás Pőcze d84101d97f pw-link: free target_link objects at the end 2024-02-27 08:32:56 +00:00
Wim Taymans 09e0113b6a stream: FORCE_RATE should just contain the rate 2024-02-26 22:18:14 +01:00
Wim Taymans 1b407d1c6d jack: FORCE_RATE should just contain the rate 2024-02-26 17:04:21 +01:00
Wim Taymans c0966f026a modules: prefix network-utils methods with pw_net 2024-02-26 15:17:48 +01:00
dsee 4888b35284 Support IPv6 link-local addresses
Use `getaddrinfo` in `parse_address` instead of `inet_pton`.
Display Ipv6 addresses with scope identifiers correctly in `get_ip`
functions using `if_indextoname`.
2024-02-25 18:20:54 +00:00
Sabri Ünal c3d3e6f48b po: Update the POT file
Add missing strings
2024-02-25 17:11:13 +00:00
Sabri Ünal 96eb9a043c Update Turkish translation 2024-02-25 17:11:13 +00:00
Pauli Virtanen 69d69ce757 examples: add MIDI example
There wasn't a MIDI example, so add one.
2024-02-24 20:47:05 +02:00