Commit graph

5302 commits

Author SHA1 Message Date
Wim Taymans
f6dbd75e61 context: rework node states some more
Make collect_nodes return a list of all nodes that are in some way
linked to the node and need to be scheduled as a group.
Move all the collected nodes to a driver, a fallback driver or away
from a driver.

This fixes some cases where nodes were moved quickly between drivers,
causing a lot of activation messages to be sent and fds to be dupped.
Nodes should now only move when needed with minimal amount of
changes to their state.

See #2309
2022-04-20 13:11:14 +02:00
Wim Taymans
cc7aadde8a connection: debug when we close fd
Also handle DUP failure.
2022-04-20 12:13:41 +02:00
Wim Taymans
a112446dab contect: also remove the original node passive state
When we have a non-driver node, also remove the passive state when
we find active links to another node.

Fixes #2309
2022-04-20 10:44:50 +02:00
Wim Taymans
e21efd40bb context: make sure we clear the visited flag
Do a separate pass to clear the visited flag of the nodes because
collect_nodes might set them after we cleared them.
2022-04-20 10:43:57 +02:00
Wim Taymans
32b2377de3 pw-cat: don't start drain on 0 request size
When the stream requests a 0 size buffer, don't start the drain but
simply queue a 0 size buffer.

Sometimes, switching quantums and drivers might request a 0 buffer
async and this should not cause a drain operation.
2022-04-19 18:29:47 +02:00
Wim Taymans
cbef4a601f pw-top: improve error output
Print +++ when the node was signal/awake but not awake/finish.
Print --- otherwise.
2022-04-19 17:49:46 +02:00
Wim Taymans
ee2b20a55c pw-top: handle invalid timings
Handle invalid signal, awake and finish timings by placing
*** instead of huge numbers.
2022-04-19 17:35:51 +02:00
Wim Taymans
e3ff445d4b pw-top: clear errors when idle 2022-04-19 12:26:20 +02:00
Wim Taymans
be11da540a pw-top: clear measurements when idle 2022-04-19 12:23:48 +02:00
Wim Taymans
ae8c6f827b pw-top: remove nodes from driver when idle
When we detect that no new profiler info has arrived for a node, assume
it was removed from the driver.

This avoids having idle nodes seemingly attached to an idle driver
when there is no activity.
2022-04-19 12:06:53 +02:00
Wim Taymans
26db2f1ec9 module-pulse-tunnel: clear ringbuffer on cork 2022-04-19 10:51:45 +02:00
Wim Taymans
182b3c8798 context: rework state calculations
We can only call collect_nodes() once because it sets the visited state
to true.
So, move the unassigned nodes to the fallback driver but when they are
passive (nothing is linked), move them back to the NULL driver.

This fixes a case where when the fallback driver changes, only some
nodes are moved to the new driver (because the other ones were already
visited in the collect_nodes() check before).
2022-04-19 10:39:38 +02:00
Wim Taymans
4cc0082634 module-pulse-tunnel: move some info log to debug 2022-04-19 09:58:18 +02:00
Wim Taymans
cdbdcd6771 module-pulse-tunnel: improve error recovery
Track the end-to-end latency of the stream and use that to drive
the resampler.
Hard reset the ringbuffer when under/overflow happens so that we
can recover quickly.

See #2230
2022-04-19 09:41:28 +02:00
Wim Taymans
c73c852413 pulse-tunnel: improve debug 2022-04-18 16:48:10 +02:00
Wim Taymans
ae194b6fe7 context: don't move passive nodes to fallback driver
Don't move passive nodes to the fallback driver when !always_process.

When we have a fallback driver, check if the node we want to add to it
is not a passive node (by doing collect_nodes), if it's passive and
doesn't always need to be processed, remove it from the driver.

This fixes the issue where nodes that are maked as want_driver are
unconditionally moved to the fallback driver (and activated) even if
there is nothing linked to them (passive).

Fixes #2309
2022-04-18 16:40:40 +02:00
Wim Taymans
1809a84562 context: ignore inactive nodes some more
Don't try to follow inactive node links.
Don't assign inactive nodes to a fallback driver.
2022-04-18 15:27:09 +02:00
Wim Taymans
0b96b87331 thread: implement some properties
Make helper method to parse thread properties and add 2 new properties
to control name and stack-size of the thread.
Use properties when creating threads with the default utils.
Use the default thread utils instead of pthread_create so that the
properties are used.
2022-04-18 13:02:27 +02:00
Quentin Wenger
d2250e9d1c Cleanup argument names in methods and events interfaces: object/data, 2nd pass. 2022-04-18 07:49:35 +00:00
Barnabás Pőcze
e28a052105 treewide: retain sections to prevent linker garbage collection
The linker may remove sections that are actually used when
"--gc-sections" and "-z start-stop-gc" is set. Add the `retain`
attribute to prevent that.

Furthermore, fix the alignment for `pwtest_suite_decl` objects.

See: #2292
See: https://lld.llvm.org/ELF/start-stop-gc.html
See: https://github.com/systemd/systemd/issues/21847
See: https://github.com/systemd/systemd/pull/21855
2022-04-15 23:58:05 +02:00
Quentin Wenger
22fc9eec35 Cleanup argument names in methods and events interfaces
First method argument is object, first event argument is data.

Closes !963
2022-04-15 10:11:49 +02:00
Wim Taymans
b0dcfa886d context: add some comments 2022-04-14 10:16:20 +02:00
Wim Taymans
2268d1838b context: re-evaluate quantum/rate for moved nodes
When a node is moved from one driver to another, recheck if the new
driver needs a quantum/rate change.

Because the node was running on the old driver, the locked flag was
checked and applied to the new driver, causing the new driver to keep
running with the old (possible wrong) quantum/rate.

Fixes #2293
2022-04-14 10:12:54 +02:00
Wim Taymans
ecff225b11 pw-cat: remove code to list targets
Introspection of default devices should be done elsewhere.
2022-04-13 16:02:46 +02:00
Wim Taymans
78b1c4c2e8 module-echo-cancel: put audio.position on properties
So that a default channel layout is set and the volume can be set before
the streams are negotiated.
2022-04-13 11:15:10 +02:00
David Weber
df6fb25e03 apply force-s16 quirk also to teams-insiders
teams-insiders is the test version of teams.
Unfortunately it still requires the force-s16 quirk
2022-04-12 10:24:05 +00:00
Wim Taymans
164361484f channelmix: tweak defaults a little.
Increase the FC filter frequency to 12KHz for better dialogs. This
filter is only applied when making the FC from FRONT channels so that
we keep the high frequency signal on the FRONT mostly.
Increase LFE filter frequency to make slightly more bass.
Disable widen filter by default.
Update config files with the correct defaults.
2022-04-12 12:04:55 +02:00
Wim Taymans
b97327e1f6 module: handle type register errors
Registering an export type can give an error when the type is already
registered. Handle those errors and refuse to load the module.

See #2281
2022-04-11 21:15:13 +02:00
Barnabás Pőcze
37fa911a72 pulse-server: module: rework registry
Move all module methods into the `module_info` struct, and place
all such structs into the "pw_mod_pulse_modules" section of
the executable. This way there is no need for an explicit
module registry, and all information about a module can
be declared in the module's source file in a single place.
2022-04-11 03:02:08 +02:00
Wim Taymans
6ad6300ec6 pw-reserver: add a -r option to RequestRelease
When we try to acquire a Device and things are busy, try to
RequestRelease the device if the -r option is given.
2022-04-08 12:12:58 +02:00
Wim Taymans
0c97008291 impl-node: improve node_set_active for exported nodes
Exported nodes (streams, filter) are not registered in the local
context and notify the server when they change active state.

When the node becomes inactive, this triggers a message to the server to
make the node inactive, which then eventually results in a PAUSE request
on the node, which then removes the node from the processing loop.

Unfortunately, clients expect that after a node is set inactive, the
process function will not be called anymore and they might free any
resources immediately. Handle this by removing the node from the
data-loop and waiting for completion.

This should fix some crashes when streams are stopped.
2022-04-06 13:03:30 +02:00
Wim Taymans
d19650178f docs: fix pw_deinit() docs
See #2238
2022-04-01 19:09:56 +02:00
Wim Taymans
cc39644253 modules: add pid to unique name
So that modules loaded from different processes don't generate the
same node names.
2022-04-01 15:22:48 +02:00
Wim Taymans
f9e8e689d3 filter-chain: free descriptor
Fixes #2220
2022-04-01 10:10:22 +02:00
Wim Taymans
da10a2ad60 context: destroy data-loop in free
Just stop the data-loop before destroying the modules because they might
still try to access it.
Destroy the data-loop in the free phase instead.

Fixes a valgrind error where module-rt tries to clear the thread-utils,
which causes the context to try to clear the thread-utils on the already
freed data-loop.
2022-04-01 09:58:46 +02:00
Wim Taymans
4a5129bdb4 fix stream test 2022-03-31 10:38:51 +02:00
Wim Taymans
5d31ec74ac stream: report queued and dequeued buffers in pw_time 2022-03-31 10:19:05 +02:00
Wim Taymans
0503ced8ab pw-cat: set buffer size field in frames
So that we get a meaningful value for the pw_time.queued field.
2022-03-31 10:16:15 +02:00
Wim Taymans
5ec7a9f40c pw-cat: start timer when playing 2022-03-31 10:15:57 +02:00
Wim Taymans
c6a8f8d3ef global: use SPA_ID_INVALID to send serial id
We use the done event to send the object serial to the client. Use an
invalid object id for this and filter it out on the receiver or else
the client might get an unexpected done event.

Fixes #2253
2022-03-31 09:39:49 +02:00
Carlos Rafael Giani
e8f93c3e1e meson: Add option to enable/disable legacy RTKit module
The RTKit module is being replaced by the RT module. Currently, it is
always built if D-Bus is present. For packagers, it can be beneficial to
be able to disable the legacy module. Add a Meson option to allow for
exactly that. Make it enabled by default to not change default behavior.
2022-03-31 07:07:40 +00:00
Wim Taymans
f0424c0b99 thread: deprecate pw_thread_utils_set()
Setting a global thread-utils is not a good idea, especially
when multiple contexts will register their own interface.

Instead, set the thread-utils as a context object and use this to
configure the data loop in the context.

In JACK we need a per context implementation of the interface so that
we can find the context specific thread-utils.

See #2252
2022-03-30 20:39:34 +02:00
Wim Taymans
3c38794886 pulse-tunnel: recover from xruns better 2022-03-30 17:59:25 +02:00
Wim Taymans
da6687e6ec module-pulse-tunnel: use dll to keep latency under control
Assign half the latency to the internal ringbuffer and half on the
network and remote end.
Use a dll to calculate the drift from our target ringbuffer fill
level and use the stream rate property to driver the resampler.

This should reduce uncontrolled latency over the tunnel.

PulseAudio wants us to be a driver will pull requests from the remote
side. We would need to provide a clock based on the remote end and
also try to follow it when we are not a driver. It would be slightly
better because in the normal playback case we would be able to
avoid resampling. We might do this eventually.
2022-03-30 17:23:09 +02:00
Wim Taymans
42d689edf2 stream: add support for double controls
We convert them to and from float.
2022-03-30 17:15:59 +02:00
Wim Taymans
2f5bba112f spa: Improve PropInfo fields
The PropInfo either has a registered id (and then also a name from the
type-info) or a custom name as a string.
In all cases, the description contains a free form text that clarifies
the property.

Use the description in the stream controls name.
2022-03-30 17:09:08 +02:00
Wim Taymans
4ae94a6ca6 modules: use NODE_WANT_DRIVER=true instead of NODE_GROUP
For the modules that require a driver, don't add ourselves to
the pipewire.dummy group but instead just use the NODE_WANT_DRIVER
property to be assigned to a driver.

This makes it possible for the nodes to move to another driver than the
dummy driver (which has very high priority) and it avoids resampling in
cases where the nodes are linked to an audio source or sink.
2022-03-30 14:56:28 +02:00
Wim Taymans
01b4c4fa64 context: keep the driver passive when we can
Only make the driver node active when we assign it an always_process
node. Otherwise we can keep the driver passive until some other active
nodes are added.

Fixes a case where an need_driver node would automatically activate
the driver, even when nothing is to be scheduled.
2022-03-30 13:26:07 +02:00
Wim Taymans
8ec3932e97 pulse-server: include buffered data in stream delay
The buffered data includes the extra samples used by the resampler.
2022-03-29 17:41:14 +02:00
Wim Taymans
5a9d2679ca stream: add pw_stream_get_time_n()
Deprecate pw_stream_get_time() in favour of _get_time_n() that contains
the size of the pw_time structure. Make the old one fill in the fields
up to the buffered field. Make the new one use the size to decide how
much info to fill in.

Add a new buffered field in pw_time that contains the buffered data
inside the converter/resampler. This leaves the queued field with
purely the user provided size in the buffers.

Use get_time_n() in places.
2022-03-29 17:30:38 +02:00