Commit graph

5335 commits

Author SHA1 Message Date
Wim Taymans
865d41b986 pulse-server: module does not depend on client
We don't need to pass the client to the module create and load
functions, they can work without a client.

The only place the client is used is to access the properties to make a
new connection to pipewire. This is also however not a good idea, we
should simply use the defaults used by the context or else a client
could set strange properties like remote.name etc for these internal
connections.

Also removing the dependency of the client will make it possible to load
modules from the startup script or other modules later.
2022-12-06 18:26:29 +01:00
Robert Mader
2ed7afb76c gst: Implement SPA_META_VideoTransform support
Many Gstreamer elements support transforming buffers via the
`image-orientation` tag. Use it to implement support for the new
VideoTransform meta.

In order for Gstreamer pipelines to enable support for these tags
usually the rotate method has to be set to `auto` or `automatic`,
e.g. `videoflip method=automatic`, `glimagesink rotate-method=automatic`
or `waylandsink rotate-method=auto`.
2022-12-05 18:40:00 +01:00
Wim Taymans
9f2abea480 module-loopback: deactive both streams before destroying
First deactivate both streams so that they are not calling eachother
anymore and then destroy the streams.
2022-12-05 16:05:37 +01:00
Wim Taymans
5b371048df stream: always try to recycle a buffer
Also try to recycle a buffer if the current buffer_id is invalid.
Ignore -EPIPE from the sender, just ask for more data. -EPIPE is when
the sende runs out of buffers so in that case we need to recycle one
as well.

Fixes #2874
2022-12-04 12:51:45 +01:00
Wim Taymans
dd420934ce impl-node: start driver node after followers completed
Wait for all pending Start commands from the followers to complete
before adding and starting the driver node.

This ensure that all links are set up and the nodes have received and
replied to the Start command and things can start without hickups.
2022-12-03 20:38:26 +01:00
Wim Taymans
a5f23224d1 impl-node: activate links immediately
Don't wait for the node to be added to the graph before we activate
the links to it.

We don't do the reverse for shutdown and the activation counters won't
actually be updated until the node is added.

Waiting can cause race conditions in some specific cases (see in
screen sharing unit test) because the driver node can start
pushing buffers before the link has sent the Buffer io area to the
ports.

With this fix, the receiver (input stream) will first trigger
the input link activation, then the Start command and then it will be
added to the graph.

This does not entirely fix the race conditions when starting. Ideally,
the driver node should wait until all pending Start commands of the
nodes in the graph have completed.
2022-12-03 20:35:07 +01:00
Wim Taymans
99c150a613 stream: handle some invalid situations
Give an error when try to set more buffers than allowed.
Make sure we only queue buffers with a valid id.
2022-12-02 10:58:13 +01:00
Wim Taymans
a20101c58c pulse-server: Add IPv4 address first in server list
So that zeroconf-discover prefers to publish with the IPv4 address
because that is likely more successfull.

See #2861
2022-12-01 20:17:08 +01:00
Wim Taymans
cacfc74786 impl-node: improve handling of removed nodes
First we remove the node from the graph, then we disable all links
to it and then we Pause the node. It's possible that the node is still
scheduled while we remove the links. In this case we should not schedule
the node but resume the peer nodes. Also don't log a warning in this
case as it is expected.

Also don't log a warning when a node emits a ready event while it was
removed from the graph. This is also expected because we first remove
the node from the graph and then send the Pause/Suspend command to make
it stop emiting the ready events. Just ignore the event when this
happens.

See also !1449
2022-12-01 15:53:52 +01:00
Jonas Holmberg
968508cf4d impl-node: Don't schedule non-active node
Avoid scheduling non-active nodes by removing the eventfd source from
the data loop when the node is deactivated. Read any old value from the
eventfd when starting the node again in case it has been written to
while the source was removed from the loop.

The ready callback can still be called when the node isn't active since
it is not called via the eventfd.
2022-11-30 17:02:00 +01:00
Barnabás Pőcze
c933c5ed74 pipewire: module-zeroconf-publish: only unpublish service when necessary
When a server is stopped, only unpublish those services
that have been published with that particular server,
do not touch the others.
2022-11-28 14:54:04 +01:00
Wim Taymans
5f000b007d filter-chain: optimize copy plugin
A copy plugin at the input ports can be replaced by directly writing
into the peer input ports so that we can avoid a memcpy.
2022-11-27 11:56:00 +01:00
Wim Taymans
f673764e58 filter-chain: use optimized sum 2022-11-27 11:55:55 +01:00
Wim Taymans
ca8bc59d0a filter-chain: add biquad to dsp functions 2022-11-24 19:14:34 +01:00
Wim Taymans
be1d4940a3 protocol-native: initialize fields
Set some of the fields to default values.

Fixes #2852
2022-11-24 09:40:14 +01:00
Wim Taymans
0f79014e18 filter-chain: add some optimized mix functions 2022-11-22 17:59:44 +01:00
Wim Taymans
9d8edef1a0 client-node: guard against NULL resource
When destroying, the resource can be NULL (mix->io should also be
NULL ideally so we can check first).

See #2847
2022-11-21 20:20:16 +01:00
Barnabás Pőcze
67e77d13f6 client-node: set port data before calling _set_mix()
First set some of the port flags and data, especially the owner_data
before calling pw_impl_port_set_mix(), which will use the owner_data
to send the mix_info.

See #2847
2022-11-21 20:15:39 +01:00
Wim Taymans
8e9b136b10 jack: use node.passive to make passive links
Let the node.passive property make passive links. PIPEWIRE_LINK_PASSIVE
overrides the node property.

Add some nice tweaks for qsynth so that it suspends and fades out
nicely by default.
2022-11-21 16:02:30 +01:00
Wim Taymans
ead59e750f stream: get info from Position in Start
When we start, read the Position IO so that we collect the right quantum
etc before calling the process callback. This updates the requested
frames value in the buffer correctly with the current quantum instead of
using 0.

This fixes an issue in pw-cat with midi data. The first buffer has a
requested size of 0 and so the first events won't fit in it and are
discarded.

Fixes #2843
2022-11-21 15:22:33 +01:00
Wim Taymans
0918899bf8 client-node: send the mix_info before Buffer IO
We don't always need to send buffers to a remote port, when the port
is an output port, all the mix ports use the same buffers. This means
that when we add another link to a port, we don't get the mix_info
anymore and then we don't know the peer_id and we don't complete the
link and we don't call the connection_callback.

Instead, send the mix_info right before sending the Buffer Io area. We
always do this for all mix io and after we have sent the buffers so this
is a better place.

Fixes #2841
2022-11-20 19:24:01 +01:00
Wim Taymans
a0adb52124 pulse-server: add a pulse.idle.timeout option
When a client is not sending any data when it should be and causes an
underrun, mark it as idle and record the timestamp.

When a client is idle for pulse.idle.timeout seconds, set the stream
as inactive. When more data is received, set it back to active.

Add a pulse.idle.timeout option to set a global server default or
a per-stream value. Set the server default to 5 seconds. A value of 0
can be used to disable this feature.

With this change, badly behaving clients that are not sending any data
will be paused so that the sinks can suspend to save battery power.

Fixes #2839
2022-11-20 16:20:05 +01:00
Wim Taymans
b1c0662a00 pipewire-pulse: improve parsing of defaults
When we fail to parse a fraction from the config, give a warning and
continue with the default settings.
Print the final parsed value as debug.
2022-11-20 16:19:24 +01:00
Wim Taymans
fc159be9c6 pulse-server: make method to pause/resume stream
Make a method to pause and resume a stream and keep track of the paused
state of the stream. Use this function instead of setting the stream
inactive/active so that we get nice logging for each state change.
2022-11-20 16:19:24 +01:00
Wim Taymans
72912c9589 pulse-tunnel: improve latency property docs
To make it clear it needs to a number only (without ms at the end)
2022-11-17 19:04:46 +01:00
Wim Taymans
3085e312b6 pulse-server: handle server started and stopped events
When a server is started, try to publish the pending services.
When a server is stopped, republish the services.

This makes it possible to load and unload the tcp protocol after loading
the zeroconf publish module and it will do the right thing.
2022-11-17 18:36:47 +01:00
Wim Taymans
a11612bdad pulse-server: add event to the implementation
Add events when a server is started and stopped
2022-11-17 18:31:23 +01:00
Wim Taymans
ab5fe8957b pulse-server: use running servers to publish zeroconf
Loop over the servers and use its family and port to publish the
zeroconf services.

This avoids exposing the services when we don't have any TCP servers
running to accept connections.

It also avoids exposing the services twice with both IP4 and IP6
addresses.

It also exposes the services with a port that is actually usable, in
case it's not the same as the default port.
2022-11-17 17:07:38 +01:00
Wim Taymans
80983b9fb6 examples: improve console output
Go back up right before we're going to draw so that we're always at
the bottom when we quit because of ctrl-C.
2022-11-17 15:56:39 +01:00
Wim Taymans
945529f029 modules: actually copy the network property to the stream
Fixes #2384
2022-11-17 15:56:39 +01:00
Wim Taymans
88dec1d378 impl-module: turn warning into info
Errors while loading a module does not have to be fatal, it depends on
the config flags. Turn an error into info and log an error only
when needed.
2022-11-15 09:41:48 +01:00
Gleb Popov
525e7aa734 FreeBSD build fixes. 2022-11-14 21:03:22 +03:00
Gleb Popov
018058ea35 Fix copy-paste typo in the warning message. 2022-11-14 20:58:14 +03:00
Gleb Popov
781b7b187a Add a type cast necessary to compile on FreeBSD. 2022-11-14 19:57:08 +03:00
Wim Taymans
b913f1b1a7 add some more debug 2022-11-14 11:23:12 +01:00
Wim Taymans
41d8afa404 pipewire: increase max-rates to 32 2022-11-13 09:40:49 +01:00
Wim Taymans
ea4e5cf364 context: avoid useless graph recalculations
Only recalculate the state of the graph when we actually managed to
suspend a driver node.
2022-11-11 19:41:49 +01:00
Wim Taymans
518ccdf624 jack: add jack.filter-char to specify the filter character 2022-11-10 17:40:25 +01:00
Wim Taymans
b720da771e pulse-server: also advance read pointer in underrun
So that we ask for more data from the client.

Also retested with #2799 that caused this regression.

Fixes #2821
2022-11-10 16:13:33 +01:00
Wim Taymans
e3ece6db54 gst: hide the libcamera device provider 2022-11-10 09:38:46 +01:00
Julian Bouzas
bc2a02c283 echo-cancel: add option to make echo-cancel sink node a monitor
The monitor mode does not create a echo-cancel-playback node, and makes the
echo-cancel-sink node to be a monitor node with media class Stream/Input/Audio
(instead of Audio/Sink).

Some applications get confused when their output stream node is not linked
directly to the actual device node. Having echo-cancel-sink as a monitor node
avoids this problem, allowing those applications to work properly even if echo
cancel is enabled.

This mode is disabled by default. You can enable it by passing the specific
option  (monitor.mode = true) in the args when loading the module in the
pipewire context.modules configuration section.
2022-11-07 17:21:21 +00:00
Wim Taymans
34db6b80c6 context: improve graph rate selection
If a node suggests a graph rate that is not in the list of allowed
rates, find the closest matching rate in the allowed rate instead of
just using the default.

When playing a file with a rate of 352800 and allowed rates of 44100,
48000, 96000 (default rate 48000) this will switch the graph to 96000
instead of the default 48000, which requires less resampling.
2022-11-07 17:58:16 +01:00
Wim Taymans
02add5b3db impl: don't return -ENOENT when no params
We checked above if the param is supported and return -ENOENT already.

When we actually go enumerate the params but don't have any, return 0
and not an error.

Fixes wireplumber#370
2022-11-07 12:36:15 +01:00
Wim Taymans
7631316186 buffer: add option to reverse filter priority
By default, buffer negotiation favours the default property values of
the output node. Make this configurable and reverse this logic when the
output is a driver.

This makes it so that a stream connecting to a source will negotiate
with the preferences of the stream and not the source.

An example is a stream that wants 4 buffers from v4l2-source, because
v4l2-source has a default of 4 buffers, this will always result in 4
buffers, ignoring the preference of the stream.
2022-11-04 15:22:01 +01:00
Wim Taymans
44d743ed95 spa: make all format parsing fields optional
Just like the optional build, make all field parsing optional. This
will leave the fields with their default values if they are not parsed
from the param.

We can then remove our custom functions and use the generic ones in
various places.
2022-11-03 13:13:07 +01:00
Wim Taymans
74447acedb Add some more format checks
The format parse functions don't really check if the parsed values
make any sense so we need to to this ourselves.
2022-11-03 13:10:32 +01:00
Wim Taymans
c30d743198 pw-top: initialize info struct with 0
So that we don't accidentally print uninitialized values.
2022-11-03 13:08:48 +01:00
Wim Taymans
e3a4797063 pw-top: support MJPG and H264 formats 2022-11-02 17:14:40 +01:00
Wim Taymans
3e4da8e8e4 filter-chain: emit en error when graph fails 2022-11-02 12:58:37 +01:00
Wim Taymans
f6e76f8356 filter-chain: add more default LADSPA search paths
Add /usr/lib/ladspa and LIBDIR to the default search path as well.
2022-11-02 12:57:16 +01:00