Commit graph

5263 commits

Author SHA1 Message Date
Wim Taymans
5f30ccae50 pipewire: remove redundant code
The generic code can now also handle the single character debug
specification.
2022-12-14 18:54:50 +01:00
Wim Taymans
9b3b6e2401 pipewire: support global log level in PIPEWIRE_DEBUG
Add support for PIPEWIRE_DEBUG=3,foo.bar:5 to set a global log level in
addition to specific topics.

Previously it would have to be done with *:3,foo.bar:5, which would not
really set a global level but all topics to the custom level of 3.
2022-12-14 18:00:54 +01:00
Wim Taymans
72bee99f87 pulse-server: add category for connection debug
Use a new conn. topic to debug the messages. These are disabled by
default.
2022-12-14 16:40:58 +01:00
Wim Taymans
34973eac89 pipewire: fix pw_debug_is_category_enabled()
The function was broken since the log topics were added.

Use the logger to init a topic with the given name and check if
there was a custom level for the topic.
2022-12-14 16:20:23 +01:00
Dylan Aïssi
cbc75dc98d pw-mon: recognize -N and -C as valid options 2022-12-14 11:07:42 +01:00
Wim Taymans
144df8675f audioconvert: enable channelmix.mix-lfe by default
It seems OK and SDL also seems to mix LFE by default so what could
possibly go wrong.

Fixes #2425
2022-12-13 16:29:46 +01:00
Wim Taymans
61750813ff filter-chain: move buffer resample to separate function
Fix the error paths.
Rename some variables around to make things clearer.
2022-12-13 12:18:46 +01:00
Dmitry Sharshakov
28af79be79 filter-chain: convolver: flush, add resampler quality option
Robustness fix: don't truncate IR, free the resampler state after use.
2022-12-13 10:09:55 +00:00
Dmitry Sharshakov
7950d3ff0d filter-chain: convolver: resample IR
Ensure correct filtering when node rate does not match filter rate
2022-12-13 10:09:55 +00:00
Wim Taymans
b5c21c1fbc pipewire: use dlclose unless PIPEWIRE_DLCLOSE is set to false
Always dlclose the libraries but use PIPEWIRE_DLCLOSE to override this
behaviour.

Fixes #2786
2022-12-12 17:11:04 +01:00
Wim Taymans
b29200ee82 pulse-server: add a pulse.cmd section
Add a new config section that can contain a set of commands to run after
starting.

There is only load-module available now but it can be used to remove the
dependency on pactl when starting the server.
2022-12-12 16:46:16 +01:00
Wim Taymans
87d2719148 utils: expose pw_split_ip 2022-12-12 16:45:30 +01:00
Barnabás Pőcze
3bdd2e01c5 pipewire: store SPA handles in a global list by age
Operating on the assumption that every SPA handle
can reference any other older SPA handle, the only
safe destruction order is from youngest to oldest.

To achieve this, store all handles across all plugins
sorted by age (youngest first), and use that as the
order of destruction in `pw_deinit()`.

This line of thinking does not account for what happens
when a handle that is referenced by others is unloaded,
but it does not make that case worse either.

See #2881
2022-12-10 00:46:37 +01:00
Wim Taymans
45235172c8 pulse-server: disable idle.timeout by default
Only enable pulse.idle.timeout for selected applications
(speech-dispatcher) and let other applications be. We can also
lower the minreq and min-quantum of speech-dispatcher now.

Fixes #2880
2022-12-09 10:00:32 +01:00
Wim Taymans
a6f8790ece pw-top: log core errors, silence other errors with info 2022-12-08 17:29:19 +01:00
Wim Taymans
ced0f853a1 impl-node: improve state change when driver changes
Imagine this case with pw-loopback:
 - the output stream is created and connected
 - the input stream is created and connected
 - the output stream is linked first and input+output move to the
   sink as the driver. Start is sent to input+output but delayed
   for the driver until all is complete.
 - the input stream is linked to a source. The source becomes the
   new driver and input+output+sink is moved to the source.
 - all completes, the source is sent the Start command because it is
   a driver. The sink also completes but is not sent a Start Command
   because it is no longer a driver.
   -> sink is scheduled but not started and gives errors

This patch clears the pending state of a driver when it is no longer
a driver. This makes the new driver set a new state (and cancel the
old state) and all followers will start correctly.
2022-12-08 16:24:52 +01:00
Wim Taymans
638de5a3b7 gst: set stride to 0
We don't really know any better yet.
2022-12-08 13:39:58 +01:00
Wim Taymans
8db85cf198 examples: handle 0 stride better
Assume the stride is size/height in case someone doesn't set the stride
correctly.
2022-12-08 13:39:58 +01:00
Jonas Holmberg
83f1de95c0 module-loopback: connect playback before capture
Connect the playback stream before the capture stream since the capture
stream can otherwise trigger playback_process() before the playback node
has been activated.
2022-12-08 13:31:45 +01:00
Wim Taymans
dee2a51eb0 impl-node: don't pass the -EBUSY to the caller
Let the caller receive EBUSY from the _set_state method instead of
an error code to make sure it doesn't go into error.
2022-12-08 12:38:36 +01:00
Wim Taymans
9bf6fa05d1 module-rtp-sink: silence some messages 2022-12-08 12:10:22 +01:00
Wim Taymans
2f397035b8 modules: don't call pw_stream_set_control in process
pw_stream_set_control can only be used from the pipewire main_loop, not
the process callback. Instead, use the rate_match field directly.

Fixes #2633
2022-12-08 11:01:24 +01:00
Wim Taymans
40f58f43fb impl-link: small cleanups
Use inode and onode for input and output nodes when deactivating, like
we do for activate.
2022-12-07 21:56:24 +01:00
Wim Taymans
19964963d3 impl-node: don't do IPC from data-loop 2022-12-07 21:19:57 +01:00
Wim Taymans
7b61bf8c8a improve debug 2022-12-07 16:01:16 +01:00
Torkel Niklasson
126bcd200b modules: Change some core errors to info
Modules echo-cancel, filter-chain and loopback may print errors if no
applicable target nodes exist when they start up. For our products this
is not considered error/warning worthy, since the issue will resolve
itself once the target nodes exist.
2022-12-07 11:36:30 +01:00
Wim Taymans
37439d2b73 pulse-server: add gsettings module
Uses a thread to monitor gsettings data. Loads and unload modules
based on gsettings.

This makes paprefs work.
2022-12-07 09:45:43 +01:00
Wim Taymans
89d4cafec4 pulse-server: fix module args 2022-12-06 19:02:02 +01:00
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