Commit graph

6474 commits

Author SHA1 Message Date
Wim Taymans 61dbad2cf3 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-19 13:20:29 +01:00
Wim Taymans 0e380de809 conf: improve matching rules a bit more
Handle "null", null, !null, "!null", !"null" and "!\"null\""
matches, copy some docs from wireplumber about the rules and
add some more cases.
2024-03-18 17:53:44 +01:00
Charlie Li 2821b05d0b 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-16 14:39:00 -04:00
Wim Taymans 2c0d73ab49 gst: handle latency in the pipewiresrc
Get the delay in the graph and subtract this from the cycle start time
to get the timestamp of the buffer.

Report this latency as well.

Fixes #30
2024-03-15 17:31:43 +01:00
Wim Taymans 1fe498560b gst: refactor some of the param handling
Clear the caps when the param is NULL.
2024-03-15 17:31:05 +01:00
Wim Taymans 2bd85e08cf gst: parse the audio rate from caps
Parse the audio rate from the caps and set this as the stream node.rate
property. This will try to switch the graph to this rate and avoids
resampling.

Rework some of the property handling.
2024-03-15 17:27:32 +01:00
Wim Taymans 9f74a31e9e include: install new header 2024-03-15 13:18:22 +01:00
Wim Taymans 9c072832f0 tests: cleanup correctly to avoid leaks 2024-03-15 13:08:58 +01:00
Wim Taymans c2ba66bef6 protocol-native: clean up security context on unload 2024-03-15 13:00:30 +01:00
Wim Taymans df50952f48 tests: add right include for close/unlink/pipe2 2024-03-15 12:39:20 +01:00
Wim Taymans 76ce2f77a4 test: handle running without a server
The security context test requires a running server, exit gracefully for
now when there is server running, like in the CI.
2024-03-15 12:25:30 +01:00
Wim Taymans 7e9e261fa6 conf: support property rules
Add pw_conf_section_update_props_rules() that will not only update the
properties of a section but wil also apply rules in section.rules and
match against the context properties.

Use this by default when using pw_context_conf_update_props().

Add a new method to get a string name of the VM type. Place the
cpu.vm.name in the context properties.

This makes it possible to deprecate the vm.overrides with something more
flexible based on rules. Update the conf files and docs to refect this.
2024-03-15 12:10:41 +01:00
Wim Taymans afd0affd97 conf: handle !null checks 2024-03-15 12:10:40 +01:00
Wim Taymans 6c6046f5ac tests: update unit test for added field 2024-03-15 12:10:40 +01:00
Wim Taymans a69e2ecda5 gst: fall back to buffer time when no header
This at least sets some form of timestamp on the buffers.
2024-03-15 12:10:40 +01:00
Wim Taymans f0dcdf4d31 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-15 12:10:40 +01:00
Wim Taymans 8a1ed01923 protocol-native: update the properties correctly 2024-03-14 11:10:38 +01:00
Wim Taymans 9af26d1718 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-14 11:06:12 +01:00
Wim Taymans 1d8a96d240 stream: update some docs 2024-03-13 15:27:47 +01:00
Wim Taymans 69cc3832d4 tools: improve error reporting
Add better error reporting in the security context and pw-container.

Add manpage for pw-container.
2024-03-13 12:53:04 +01:00
Wim Taymans 81181e255f tools: add pw-container tool
This makes a new custom security context with the given properties
and runs the program in this context.
2024-03-13 12:53:04 +01:00
Wim Taymans 477c6e8e90 protocol-native: improve security context properties
Remove the engine_name, use pipewire.sec.engine in the properties. Make
some constants for this.

Document some more properties.
2024-03-13 12:53:04 +01:00
Wim Taymans d250f6932c protocol-native: don't allow recursive security context
Place the engine name in pipewire.sec.context and make sure that a
client with a pipewire.sec.context property can't make new contexts.
2024-03-13 12:53:04 +01:00
Wim Taymans e7846fc12a protocol-native: add security context API
Add a new extension that can create a server on a user provided socket
with user provided security properties.

This is mainly used in flatpaks that want to create and bind a pipewire
socket with specific permissions for the flatpak app.

The flatpak will also provide an fd that will be closed when the server
can be removed.
2024-03-13 12:53:04 +01:00
Wim Taymans c5e8da7247 protocol-native: add props to the sockets keys
Make it possible to set extra properties on the sockets created from the
config options with a props key.
2024-03-13 12:44:24 +01:00
Wim Taymans e86a68db3f gst: add a clock to gst pipewiresink 2024-03-12 17:36:50 +01:00
Wim Taymans 4437f6e000 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 16:54:50 +01:00
Wim Taymans f86ea21b19 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 12:22:34 +01:00
Wim Taymans 84af13a10b 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 10:21:31 +01:00
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
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
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
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
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
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 cbffa9c568 node: add the current driver id to the node activation
See #3873
2024-02-28 11:42:09 +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 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
Pauli Virtanen 69d69ce757 examples: add MIDI example
There wasn't a MIDI example, so add one.
2024-02-24 20:47:05 +02:00
Wim Taymans 86af9de739 adapter: remove factory.mode property
We can deduce this from the way the node is configured with the
PortParam now.
2024-02-23 16:28:11 +01:00
Wim Taymans 9b4b34b78b conf: add pulse-server option to minimal.conf 2024-02-22 16:14:34 +01:00
Wim Taymans 3c27dcd868 pulse-server: Make sure peer_sink name is filled
Use 'unknown' when we can't find the peer_name. Otherwise we will just
get a protocol error when the node.name is missing.
2024-02-19 17:39:39 +01:00
Wim Taymans 915539e6d4 stream: add n_buffers to debug log 2024-02-19 15:00:04 +01:00
Wim Taymans 94861eb3d6 doc: remove stray \code 2024-02-19 11:06:45 +01:00
Ruben Gonzalez 15bdab89c3 logger: minor performance improvement to avoid syscall done by isatty 2024-02-17 11:42:12 +00:00
Wim Taymans 764ae650e2 conf: fix override directory order
We need to load and apply the overrides in the order:

If absolute config path, use only that.
If environment variable, use only that.
Else
 /usr/share/pipewire/*.conf.d/
 /etc/pipewire/*.conf.d/
 $HOME/.config/pipewire/*.conf.d/

Before this patch we would first apply $HOME and then /etc and /usr,
which is not expected.
2024-02-16 18:16:30 +01:00
Wim Taymans c37c6b0789 module-rtp: fix SAP header parsing for IPv6
If the originating source is IPv6, the A bit is set and the source is 16
bytes compared to 4 bytes for IPv4.

Fixes #3851
2024-02-16 12:53:54 +01:00
Wim Taymans e15b9e7f71 module-rtp: fix debug log 2024-02-16 12:37:40 +01:00
Wim Taymans 09feb8a18c module-rtp: improve ipv5 support
Use the IPV6 versions for loop and ttl. Improve debug.
2024-02-16 09:54:09 +01:00
Wim Taymans 5082e9f458 module-rtp: only stop timer when it was running 2024-02-15 17:48:58 +01:00
Wim Taymans 49e7e3a0f0 module-rtp-sink: improve source.ip default
Use the default source.ip from the same address family as the
destination.ip.

See #3851
2024-02-15 15:31:54 +01:00
Wim Taymans 320eb935a3 module-rtp: handle ipv6 sap.ip
Make a socket of the same address family as the address we're going to
bind it to.

When the source.ip is not specified, use the default in the same address
family as the sap.ip.

Probe the interface for addresses of the same family as the sap.ip.

Makes pactl load-module module-rtp-recv sap_address=:: work.

See #3851
2024-02-15 15:18:13 +01:00
Wim Taymans f1a6fabb6c meson: add options to set server and client RT priority
Make a rtprio-server and rtprio-client option. Leave the server
priority by default to 88 but lower client priority to 83. JACK
does something similar by setting clients to rtprio-server - 5.

Make module-rt use the client priority by default and bump the server
priority explicitly in the config file.

Leave the pulse-server to the default rtprio-client, there is no reason
to lower this any further because it is really just a regular client.

Bump the ffado packetizer thread to rtprio-server + 5 because that is
also what JACK does.

88 is still much higher than the value of 60 that JACK uses in
Fedora but now this is at least configurable.
2024-02-15 11:53:32 +01:00
Wim Taymans a9c0eb993e jack: add jack.other-connect-mode property
Add a new property that controls how connections between other ports are
handled. This can be used to block jack apps from connecting or
disconnecting port they don't own.
2024-02-14 15:09:55 +01:00
Wim Taymans 2807a1eafd impl-node: add node.rules and device.rules
To be able to modify properties of nodes and devices. This is
interesting in the minimal config to give the nodes better defaults.
2024-02-14 12:33:41 +01:00
Dmitry Sharshakov fcea3eee01 pipewire-aes67: clarify comments 2024-02-13 16:47:56 +00:00
Julian Bouzas 0e5bbea36c pw-dot: group nodes by node.link-group 2024-02-13 16:38:48 +00:00
Julian Bouzas 20de0ab96a pw-dot: truncate escaped string values to 128
This avoids objects in the graph being too big if one of their properties has
a long value (Eg 'pipewire.sec.label' in the client objects).
2024-02-13 16:38:48 +00:00
Wim Taymans 59ea4ef897 adapter: move node.params to impl-node.c
Move configuration of initial Params from the adapter to the node to
make it more generally useful.

Add the same device.param config to devices.

This makes it possible to configure the default settings statically
while creating the nodes and devices.
2024-02-13 16:01:10 +01:00
Wim Taymans 4ab3ab6081 impl-device: set quantum-limit correctly
Pass the quantum limit also to the main node.
2024-02-13 15:55:07 +01:00
Wim Taymans 1dc822c999 impl-device: add support for adapter
Make it possible to wrap nodes created by a device in a wrapper such
as adapter.

Update the minimal.conf to use udev to detect and configure devices and
nodes. Add a config switch to switch back to hardcoded config.
2024-02-13 12:03:53 +01:00
Wim Taymans c08c335264 impl-device: add device.object.properties
Instead of copying all the device properties to the child object,
only copy the ones in device.object.properties and add the
ones from the object info.

Clean up the object handles when something goes wrong.
2024-02-13 11:37:21 +01:00
Wim Taymans ee5e1a92be impl-device: add device.id to objects
Add the device.id to the objects created from this device.
2024-02-13 10:01:02 +01:00
Wim Taymans 490d540177 modules: avoid invalid properties access
pw_spa_node_load() takes ownership of the properties so we must not
access it it afterwards, so make a copy of it.
2024-02-12 17:53:44 +01:00
Wim Taymans 513e8fa56f adapter: move adapter.auto-port-config to adapter
Move the handling of the default adapter port config to the adapter
itself.
2024-02-12 17:24:22 +01:00
Wim Taymans efd22efff8 pw-link: improve port and node names
don't leave the port and node names blank but fill in some defaults that
include the node/port id.
2024-02-12 17:14:33 +01:00
Dimitrios Katsaros 8f59508ecb metadata: Added context monitor for removed globals
impl-metadata would not monitor for globals being removed.
This would cause stale metadata to remain in the
store, causing future objects on the same ids to have invalid data.
2024-02-12 08:40:49 +00:00
Dimitrios Katsaros 17e6a0709b metadata: handle removed globals in impl 2024-02-12 08:40:49 +00:00
Gleb Popov 571fa73455 Fix uninitialized variable usage 2024-02-10 20:52:31 +03:00
Gleb Popov 6b73cc15da FreeBSD compatibility for module-rtp-sap 2024-02-10 20:52:20 +03:00
Gleb Popov 4ea02f5c80 Fix building module-netjack2 on FreeBSD 2024-02-10 20:52:15 +03:00
Julian Bouzas 64eaaf27ab pw-dot: fix modules not being linked correctly
This fixes a regression caused by commit 0b5cdf3f
2024-02-09 10:54:21 -05:00
Julian Bouzas 02050ae812 pw-dot: support properties with quotes
If a pipewire property has quotes, the DOT graph fails to be generated because
they are not escaped. This patch fixes this by escaping the quotes from a
pipewire property value before adding it to the graph
2024-02-09 14:46:40 +00:00
Julian Bouzas 0b5cdf3fd8 pw-dot: improve allocation of the DOT data string
This changes avoids constantly reallocating the DOT data string every time
someting is added. We now always allocate a DOT data string of size 2048, and
we only reallocate by size * 2 if we need more data.
2024-02-09 14:46:40 +00:00
Demi Marie Obenour 30419c37df Ensure all globals have PW_KEY_OBJECT_SERIAL prop
This avoids the caller having to set this property.
2024-02-09 14:45:05 +00:00
Wim Taymans ac28abbadf metadata: handle removed globals as well
When we remove a global, we set NULL,NULL,NULL as its metadata. This
then results in the implementor of the metadata to emit the property
change event for the subject.

When we decide to propagate this event to the listeners we not only
need to check if the client can see the global but also if the global
was removed and this is a remove metadata event.

Fixes metadata remove events when a global is removed.
2024-02-09 12:50:46 +01:00
Wim Taymans 27dbbd40c9 tools: improve indentation 2024-02-09 10:24:34 +01:00
Wim Taymans 858d4e9e1c buffer: add MAPPABLE data flag
Add a MAPPABLE data flag that hints that the fd in the data is mappable
with a simple mmap/munmap. Normally, DmaBuf is not mappable like that
unless explicitly indicated with this flag.

Set the MAPPABLE flag on the DmaBuf from v4l2 and libcamera fd.

When asked, mmap the buffer memory in all cases when the MAPPABLE
flag is set.

This solves the case where v4l2 has exported DmaBuf and is streaming to
node A and then node B links but doesn't get automatically mmaped
memory.

Fixes #3840
2024-02-08 18:09:08 +01:00
Jonas Holmberg 4715fa1775 module-rtp: Add source/destination.ip to props
Make it possible to change source.ip in module-rtp-source and
destination.ip in module-rtp-sink.
2024-02-08 09:30:58 +00:00
Wim Taymans 0ea736e144 protocol-native: use props in server and data
Add props to the protocol_data and server. Instead of storing the
server_info, just add the relevant properties for the server to the
props.

When we get a new client, we can simply copy the server props to the
client props. This makes it possible to create specific servers later
that create clients with specific properties.

Use a subset of the context properties to create servers. We only need
the CORE_NAME for now.
2024-02-08 09:53:13 +01:00
Wim Taymans 92f6239597 protocol-native: set error when add_event fails 2024-02-08 09:48:33 +01:00
Wim Taymans 0594b3ac82 metadata: fix indentation 2024-02-08 09:42:13 +01:00
Wim Taymans 1b6370ace1 meson: fix compilation when spa-plugins is disabled
Fixes #3811
2024-02-06 11:50:54 +01:00
Wim Taymans 8657caa0ac pw-cli: set quit flag on -EPIPE
When the server closes the connection in non-interactive mode, we need
to set the quit flag to avoid going into second mainloop_run() that will
just block forever.

See #3837
2024-02-06 11:10:27 +01:00
Barnabás Pőcze 5bb2224da3 pipewire: module-rt: add missing static 2024-02-05 20:01:21 +01:00
Stefan Ursella 8f2a239504 module-protocol-simple: do not cleanup client when send returns EAGAIN or EWOULDBLOCK 2024-02-05 13:26:25 +00:00
Barnabás Pőcze db3d7b88dd pipewire: module-rt: make dbus reply checking stricter
org.freedesktop.DBus.Properties.Get is supposed to return
a single variant, so check if it does.
2024-02-05 13:03:20 +00:00
Barnabás Pőcze 4da82d5475 pipewire: module-rt: do not retrieve dbus message serial numbers
They are not used, so don't query them from libdbus.
2024-02-05 13:03:20 +00:00
Barnabás Pőcze 494e6ce70e pipewire: module-jackdbus-detect: do not autostart jackdbus
There is no need to start jackdbus via dbus service activation,
because this module is only interested in reacting to the jack server
starting/shutting down, it does not actually want to make use of jack
itself.
2024-02-05 13:03:20 +00:00
Barnabás Pőcze 542e6c652c pipewire: module-portal: watch only relevant NameOwnerChanged signals 2024-02-05 13:03:20 +00:00
Barnabás Pőcze 6e609c93e5 pipewire: module-portal: do not repeat portal service name 2024-02-05 13:03:20 +00:00
Barnabás Pőcze dcb5430ff2 pipewire: module-jackdbus-detect: watch only relevant NameOwnerChanged signals 2024-02-05 13:03:20 +00:00
Barnabás Pőcze 3a20bcadba pipewire: module-rt: use dbus helpers 2024-02-05 13:03:20 +00:00
Barnabás Pőcze 91a9f816a7 pipewire: module-rt: get rid of unused DBusError
Nothing sets it, so it can be removed.
2024-02-05 13:03:20 +00:00
Barnabás Pőcze e0ea0574f1 pipewire: module-jackdbus-detect: cancel pending dbus call on module destroy 2024-02-05 13:03:20 +00:00
Barnabás Pőcze 67375965b6 pipewire: module-jackdbus-detect: use dbus helpers 2024-02-05 13:03:20 +00:00
Barnabás Pőcze 499468c19f pipewire: module-portal: cancel pending dbus call on module destroy 2024-02-05 13:03:20 +00:00
Barnabás Pőcze e7c9b26001 pipewire: module-portal: use dbus helpers 2024-02-05 13:03:20 +00:00
Pauli Virtanen c387506f63 client-node: clear buffers always when freeing mix
Avoid leaking buffers when freeing mix, in case the port was not cleared
properly.

These leaks don't seem to be occurring currently, but better be sure.
2024-02-04 12:40:34 +02:00
Pauli Virtanen 1196429c09 client-node: handle releasing mix for destroyed port
The remote end may destroy the port via client_node_port_update(),
before corresponding pw_impl_port_mix are released.

clear_port() removes all struct mix, but this prevents the
pw_impl_port_mix from being removed from io_map, which causes stale mix
ids be left in io_map, so we end up continuously allocating new io
areas.

Make lifecycle of io_map entries match port_init_mix/release_mix
exactly, separately from the lifecycle of the port and struct mix.

When freeing struct mix in port_release_mix(), make sure it corresponds
to the mix being released.
2024-02-04 12:40:34 +02:00
Wim Taymans 841c0189df stream: fix param emission for Props
Props set on the node directly should also result in emission of changed
notify when required, just like we do for params set on the port.

This accidentally used to be done because stream_update_params()
unconditionally used to emit this for us. But commit
94cde3090e changed that.

Fixes #3833
2024-02-04 11:04:23 +01:00
columbarius a1615fe6a3 vulkan: Add vulkan-blit-dsp-filter 2024-02-04 09:27:56 +00:00
columbarius 3e3a13c567 vulkan: Add vulkan-blit-filter 2024-02-04 09:27:56 +00:00
columbarius 324ec9df15 stream: conditionally wrap video streams with adapter node
If the property video.adapt.videoconverter is set the video stream
will be wrapped with the videoadapter from the videoconvert spa plugin.

This allows testing the videoadapter and videoconverters while
preserving the current behaviour. Later the chack for this property can
be dropped.
2024-02-03 22:13:03 +01:00
Pauli Virtanen 823fb91756 mem: track fd invalidation of imported memblocks
When a memblock closes its fd, have it emit signal to other memblocks
possibly sharing the fd, so they know it is now invalid.

When a memblock has an invalidated fd, it'll not allow mapping more
memory, nor match against fd searches.

This avoids bugs where kernel fd reuse causes already invalid memblocks
to be used.  Generally, higher level code should make sure memblocks get
freed in right order so that this situation does not occur, but try to
keep mempool in consistent state regardless.
2024-02-03 15:58:22 +00:00
Sergio Costas Rodriguez 4d3658b271 snap-policy: fix memory leak
This patch fixes a memory leak when there is a snap with an
invalid ID.
2024-02-03 13:08:38 +00:00
Sergio Costas fed1432172 snap-policy: ensure audio works with .deb snapd 2024-02-03 13:07:56 +00:00
Wim Taymans d7e48f3042 module-pipe: resync when ringbuffer too full
When the ringbuffer has too much data, do a resync or else we would just
have a huge delay and would try to resample to get back to the target
fill level.
2024-02-01 16:00:25 +01:00
Wim Taymans 0bc7f3f48c module-pipe: warn underrun only once 2024-02-01 16:00:25 +01:00
Théo Lebrun 28df14859a pw-link: handle link proxy removal 2024-02-01 13:35:30 +01:00
Théo Lebrun ecffe3cbd6 pw-link: handle link proxy destruction
If for some reason the proxy gets destroyed, we make sure to remove
listeners and forget the proxy pointer. We do not however delete the
target_link; we consider the proxy destruction as an error.

If another definitive state occured on the link (got to paused state,
got an error), then that event will be ignored. Else we consider it an
error.
2024-02-01 12:08:15 +01:00
Théo Lebrun 7ebc1b05d2 pw-link: --wait: allow linking with nodes
Previously, on new node event, we registered a core sync. Linking was
attempted at core sync done  but the node did not yet have time to
register its ports.

Only listen to new ports. This delays the linking attempt to when nodes
have had time to create their ports.
2024-02-01 10:47:49 +00:00
Théo Lebrun 6a7d83f051 pw-link: listen to link info events to detect link creation
Stop using sync for link creation detection. Instead, listen to link
events.

We still listen to errors, link info events are not enough. For example,
if a link already exists, we only get a proxy error and no link info
event.
2024-02-01 10:47:49 +00:00
Théo Lebrun 5169941908 pw-link: add --wait option
Now that we have a create_link_proxies() that looks for our matching
nodes/ports and creates proxies if they exist, implementing --wait is
easy.

We move the call to create_link_proxies() the core done event. If it
finds no potential nodes/ports, we keep running our loop, monitoring
new objects.
2024-02-01 10:47:49 +00:00
Théo Lebrun 54662ad209 pw-link: refactor do_link_ports() to not run the event-loop
Make do_link_ports() only create proxies. Previously it ran the event
loop once per attempted link to detect link creation errors. Rename it
to create_link_proxies() to make things clear.

Created proxies are stored into a list (data->link_targets).
create_link_proxies() returns the number of link proxies created. This
can be zero when the two matching nodes have zero ports.

Refactor main() to use create_link_proxies(), ask for a sync then run
the event loop. It will stop on sync done, and we will have received
all potential link proxy errors.

Cleanup all proxies and listeners at the end of main().
2024-02-01 10:47:49 +00:00
Théo Lebrun e8d104f7bc pw-link: move output/input option checking before main event loop run 2024-02-01 10:47:49 +00:00
Michael Tretter c224010773 conf: escape @DEFAULT_SINK@
Variables enclosed with @ are replaced with the value of the variable.
The sink.name should remain @DEFAULT_SINK@.

Escape the enclosing @ to prevent substitution of DEFAULT_SINK with an
empty string while generating pipewire.conf.
2024-01-31 14:12:30 +01:00
Arun Raghavan 0c37adb665 module-rtp: Add some sender latency validation
Just a sanity check on config.
2024-01-30 21:26:14 +00:00
Dmitry Sharshakov c6bae2742e pipewire-aes67: re-enable sess.latency.msec for sender
78055736a2 fixes jitter for multiple packets in one quantum
2024-01-30 21:41:40 +03:00
Wim Taymans 6ea9825cd1 filter-chain: connect atom ports to an empty atom
Or else the lv2 plugin might crash.

Fixes #3815
2024-01-30 16:16:56 +01:00
Wim Taymans b157d417af module-raop: don't start record in state change
We first need to do the setup, which we start when setting the Format
param.

This causes the module to unload when starting pavucontrol because it
tries to start the record in the wrong state.

See #3778
2024-01-30 15:04:01 +01:00
Sergio Costas e8fcaa5157 snap-policy: Manage ENOPROTOOPT error in aa_getpeercon() 2024-01-30 10:28:27 +00:00
Wim Taymans 78055736a2 module-rtp: add packet timer
When multiple packets need to be flushed (because sess.latency is set
and larger than ptime) use a timer to space the packets uniformly in
the current quantum to avoid bursts.

See !1873
2024-01-30 10:06:27 +01:00
Dmitry Sharshakov 06d4570ced pipewire-aes67: temporarily disable sess.latency.msec
After c37f9f9cf0 and before further improvements it won't properly work with AES67 receivers
2024-01-29 08:54:25 +00:00
Pauli Virtanen 978dbff32f doc: fix some doxygen warnings 2024-01-29 08:50:32 +00:00
columbarius d0e51dd066 examples: Add video-dsp-src example
This client creates the same output as video-src in the dsp format.
2024-01-29 08:44:25 +00:00
Pauli Virtanen 651cb7bd71 context: move registry generation checks to context methods
Add registry generation checks to pw_context methods that find globals,
(pw_context_find_global, pw_context_for_each_global), so that they are
made everywhere where a client acquires globals.

In addition to previously covered registry bind/destroy, this also
covers link creation (port/node ids) and metadata (subject ids).
2024-01-26 11:56:40 +00:00
Wim Taymans a59a551202 module-netjack2: improve channel positions
If the manager gave us a different channel count than we had by
default or configured, assume everything is AUX channels.

Also handle the case where the manager is sending more than our
MAX_CHANNELS channels.
2024-01-25 17:59:39 +01:00
Wim Taymans c37f9f9cf0 module-rtp: use sess.latency.msec also for sender
Use the sess.latency.msec also for the sender and use it to control the
NODE_LATENCY. Make it a float to be in line with the other time values.
Set is to a default of ptime, which was what it used to be.

This makes it possible to set the ptime to a smaller value than the
sess.latency.msec so that we send out multiple packets per quantum.
This will result in some bursty output for now but with a timer that can
be improved later.

Update the docs a little, mention the new rtp.ptime and rtp.frametime.
2024-01-25 15:49:41 +01:00
Wim Taymans ec825086f1 module-rtp: use helpers to convert between samples and msec
And make sure we don't do any useless float to double conversions.
2024-01-25 15:30:04 +01:00
Wim Taymans 9458367a50 module-rtp: Fix framecount vs ptime check
We should use framecount instead of impl->psamples.
2024-01-25 15:12:25 +01:00
Dmitry Sharshakov 237d282c05 pipewire-aes67: resync when offset is more than 1.5 ms
2 ms is typically considered to be late for most AES67 implementations
2024-01-24 20:55:03 +03:00
Wim Taymans e7888d4ccc support: add resync.ms option to node.driver
Move some of the tracking code for the DLL to where it is used.

Add resync.ms (default 10) option at which we give up rate adjusting
and instead do a hard resync. This results in a jump in the position
of the graph clock.
2024-01-24 17:53:15 +01:00
Wim Taymans ccd0599702 conf: add freewheel.wait option, defauls to 10 2024-01-24 17:52:32 +01:00
Mersad Jelacic 831ab5db85 thread: Change warning to info
Change warning to info in impl_acquire_rt() and impl_drop_rt().
2024-01-24 14:52:09 +01:00
Wim Taymans 306c90618f pulse-server: the device changed when EnumRoute changes
We use EnumRoute of the card to fill in the ports of the device so when
EnumRoute changes, the associated devices also needs a change event.
2024-01-24 11:22:52 +01:00
Wim Taymans bffcb2e6f1 pulse-server: implement subscribe in device-restore
Add a client that subscribes to the list of subscribers and make the
client watch for EnumFormat changes.

When a subscribed client sees an EnumFormat change for a sink, emit EVENT
to the client.

This will send the EVENT to pavucontrol when the supported IEC958
formats change so that it can update the gui.
2024-01-23 18:08:32 +01:00
Wim Taymans 979eb0278f pulse-server: reset spa_param_info.user after events
After we emited all changed events, reset the user field. This way the
event handlers can check what params are changed.
2024-01-23 18:06:45 +01:00
Wim Taymans ac91c0dc1c pulse-server: implement stream-restore EVENT
Add method to update the client routes. Add an event when the client
routes changed.

Listen for route_changed events on clients that do a subscribe on the
stream-restore extension. Emit an EVENT when the routes change.

This keeps the system notifications volumes in sync between
gnome-control center and pavucontrol and probably in other tools
as well.

Fixes #3805
2024-01-23 13:31:05 +01:00
Wim Taymans d71fb40989 pulse-server: move extension to modules
Add extension support to modules. This is a list of extension commands
that can be performed on the module.

Remove the custom registry of extensions and make proper modules that
implement the extensions.

This is more in line with what pulseaudio does. The advantage is that the
modules actually show up in the module list and that we can use the
module user_data to implement the extension later.
2024-01-23 13:31:05 +01:00
Dmitry Sharshakov bd5af4e573 module-rtp-sap: use autobind 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov 61db1f16e2 module-rtp-sap: sanity check PTP response 2024-01-22 16:41:06 +00:00
Barnabás Pőcze 1274ebe069 Apply 1 suggestion(s) to 1 file(s) 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov 44f1462711 module-rtp-sap: fix strncpy bounds 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov 9a0499b64d module-rtp-sap: fix fd leak 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov 401df6e199 module-rtp-sap: review
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
2024-01-22 16:41:06 +00:00
Dmitry Sharshakov 7abb896aef module-rtp-sap: support PTP management protocol
Request current clock sync status to know the grandmaster identity for SAP announcements
2024-01-22 16:41:06 +00:00
columbarius 7d97e47e28 videoconvert: Enable loading external converter plugins
Load the converter from the video.adapt.converter property.
2024-01-22 13:59:16 +00:00
Wim Taymans 7479ff586c stream: debug added params 2024-01-17 09:55:47 +01:00
Wim Taymans 94cde3090e stream: delay emit param changes when inside emit_param_changed
When we are notifying the application of changed params, don't emit any
changes applied to the params from within the callback with
pw_stream_update_params(). This will be done after we complete the
callback.

This also avoids reseting the change counter so that we don't
accidentally think we updated the formats param when we simply changed
some other params.
2024-01-16 16:41:15 +01:00
Wim Taymans 2242ab66dc impl-port: res > 0 means the param was modified
Only log the error when the res < 0, otherwise the param was accepted bu
modified.
2024-01-16 16:35:50 +01:00
Wim Taymans a00981ec20 module-rtp: clarify some docs 2024-01-16 15:48:24 +01:00
Jonas Holmberg da8e207de9 module-rtp-source: Use source.ip for unicast
Only listen for packets from source.ip in the unicast (v4) case by
calling connect(). If packets from any source address is wanted, set
source.ip = "0.0.0.0".
2024-01-16 14:44:00 +00:00
Wim Taymans a769a014e0 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-01-16 15:11:08 +01:00
Wim Taymans a1ecfc8d7f tests: fix ABI check for new pw_time 2024-01-15 15:53:19 +01:00
Wim Taymans 1bbaf270f8 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-01-15 15:35:33 +01:00
Sergio Costas Rodriguez 8c3cfab17b Replace even more spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez e1571404d7 Replace more spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 6506bb2f44 Replace spaces with tabs 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez fda4addf1e Fix spacing when calling functions 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 1c9016280c Move add_permission definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 67b9e9c4e8 Move context variable definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 18d0e2e850 Move variable definition inside block 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 1728b7de59 Better error logging if getting connections fails 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez ae11e61105 fix possible leak
If pw_check_flatpak() sets app_id, its value will leak when
calling pw_snap_get_audio_permissions(). This patch fixes
this.
2024-01-12 11:35:17 +00:00
Barnabás Pőcze abc4bd111b Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez b054bc2591 Use assert to check client is not NULL 2024-01-12 11:35:17 +00:00
Barnabás Pőcze c34bd9575f Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Barnabás Pőcze 69b093ebf1 Apply 1 suggestion(s) to 1 file(s) 2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez 5e20a2d570 Add missing files
Accidentally, I forgot to add snap-policy.* files.
2024-01-12 11:35:17 +00:00
Sergio Costas Rodriguez d568dcd64f pipewire-pulse: add snap permissions support
SNAP containers have two main "audio" security rules:

 * audio-playback: the applications inside the container can
   send audio samples into a sink

 * audio-record: the applications inside the container can
   get audio samples from a source

Also, old SNAP containers had the "pulseaudio" rule, which just
exposed the pulseaudio socket directly, without limits. This
is similar to the current Flatpak audio permissions.

In the pulseaudio days, a specific pulseaudio module was used
that checked the permissions given to the application and
allowed or forbade access to the pulseaudio operations.
With the change to pipewire, this functionality must be
implemented in pipewire-pulse to guarantee the sandbox
security.

This patch adds support for sandboxing permissions in the
pulseaudio module, and implements support for the SNAP audio
security model, thus forbiding a SNAP application to record
audio unless it has permissions to do so.

The current code for pipewire-pulseaudio checks the permissions
of the snap and adds three properties to each new client:

 * pipewire.snap.id: contains the Snap ID of the client.

 * pipewire.snap.audio.playback: its value is 'true' if the client
   has permission to play audio, or 'false' if not.

 * pipewire.snap.audio.record: its value is 'true' if the client
   has permission to record audio, or 'false' if not.

These properties must be processed by wireplumber to add or
remove access permissions to the corresponding nodes. That
code is available in a separate patch: https://gitlab.freedesktop.org/pipewire/wireplumber/-/merge_requests/567
2024-01-12 11:35:17 +00:00
Wim Taymans adbd081b12 array: improve pw_array
Handle extend == 0 and don't expand the array but return -ENOSPC.
This makes it possible to handle static arrays, make a function to
make this easier. Remove pw_array_add_fixed() now that we support
this with extend==0 and because it was not used.

Round up the required space to next extend so that the total allocated
size if always a multiple of the extend.

Make pw_array_add_ptr() check for allocation errors instead of crashing.
2024-01-12 12:06:13 +01:00
Demi Marie Obenour 0f533c6d64 docs: Multiple clarifications to documentation
See !1817
2024-01-12 11:55:28 +01:00
Barnabás Pőcze d8ab51a9fc pw-top: use media.name as display name
Try to use `media.name` as the display name for a node
when none of the other keys are found in its properties.

For example, `pw_stream_new_simple()` only sets `media.name`
on the created node object by default.
2024-01-12 02:12:55 +01:00
Barnabás Pőcze 9d439bac06 pw-top: update name when it changes
Recalculate the display name for a given node after its properties change.
2024-01-12 01:47:05 +01:00
Wim Taymans 9a5609de2b modules: move some spa_debug_mem to the log
Instead of dumping to stderr, write it to the log file.
2024-01-11 17:49:50 +01:00
Wim Taymans 3baba76c77 pulse-server: improve message debug
Add prefix to messages to mark sent and received messages.
Send mem debug to log instead of stderr.
Log the complete message and debug the command.
2024-01-11 12:05:29 +01:00