Commit graph

308 commits

Author SHA1 Message Date
Wim Taymans
bae0d16e09 global: don't reuse ids 2022-01-13 14:53:18 +01:00
Wim Taymans
622851001e allow scaling the quantum_limit to 65536
Make it possible to change the quantum-limit in the config file past
8192 up to 65536. This will make all plugins allocate larger buffers
so that the quantum can be increased to larger values as well,

This is interesting when dealing with higher sample rates where the
8192 sample limit will cause wakeups every 20ms at 384KHz.

See #1931
2022-01-12 18:02:40 +01:00
Wim Taymans
676bed734c context: scale max_quantum and add quantum_limit
Also scale the max_quantum with the selected rate. Add a new
quantum_limit property that is the upper limit of the quantum regardless
of the sample rate, this is usually the allocated buffer size.

See #1931
2022-01-12 17:44:45 +01:00
Wim Taymans
c97d489929 impl-node: update quantum/rate only when pending changes
Only update the quantum/rate when we have a pending change.

This works around a bug in sco-source that changes the quantum
by itself but in any case, this optimization is nice to have.

See #1905
2021-12-15 10:45:48 +01:00
Wim Taymans
2e199eba43 node: update quantum and rate at beginning of cycle
Don't directly update the quantum and rate in the driver position
when recalculating the graph or else clients might see different values
during one cycle.

Instead update another variable and copy this into the position when
we start a new cycle.
2021-12-07 18:31:13 +01:00
Wim Taymans
1b06d4d7c4 settings: Add more runtime settings
Move settings defaults initialization to the settings file.
Expose clock.rate, clock.allowed-rates and clock.quantum as runtime
settings.
2021-11-26 16:47:43 +01:00
Wim Taymans
59c4975750 global: add serial number
Add a global serial number for each global object. We can use this
to uniquely define each global.
2021-11-22 16:00:25 +01:00
Wim Taymans
7529e7c47c stream: add trigger_done event
It is emited after the graph cycle that was started with
trigger_process() completed.
2021-10-27 11:15:29 +02:00
Wim Taymans
34609389e3 filter: add event to notify command
All commands send to the filter are emited in the command event.
2021-10-19 15:27:14 +02:00
Peter Hutterer
027dd25980 pipewire: declare pw_proxy_ref/unref
Both are already SPA_EXPORT but missing from the public header file.
2021-10-13 09:13:12 +00:00
Peter Hutterer
52bd80aaa4 log: add topic loggers and a default topic
pw_log_log/logv now go through the topic-based logger using the
"default" topic. Log topics themselves can be allocated by the call
sites. The simplest way to use a topic from e.g. a module:

    PW_LOG_TOPIC_STATIC(mod_topic, "mod.foo");
    #define PW_LOG_TOPIC_DEFAULT mod_topic
    ...
    void pipewire__module_init() {
  	  PW_LOG_TOPIC_INIT(mod_topic);
  	  ...
    }

With the #define all pw_log_foo() are now routed through the custom
topic. For the cases where the log topic must be specified, a
pw_logt_foo() set of macros is available.

Log topics are enabled through the PIPEWIRE_DEBUG environment variable
which now supports globs, e.g. PIPEWIRE_DEBUG="*:I;mod.access:D"
to enable global INFO but DEBUG for the access module.

Namespaces documented are "pw", "mod" and "conn", for pipewire-internal
stuff, modules and connection dumping. The latter is special-cased to
avoid spamming the log files, it requires an expcit "conn.<glob>"
pattern to enable.

The "default" topic always exists and is the fallback for any
pw_log_foo() invocation that does not use a topic.
2021-09-28 09:35:38 +02:00
Wim Taymans
7543ad0766 impl-node: add node.transport.sync property
When the node support transport sync. That is, when it will clear the
pending_sync flag from its activation area when it completed a new
seek.

Before this patch, the pending sync was always automatically cleared,
which broke some applications that are time masters such as bitwig.

Fixes #1589
2021-09-14 11:06:19 +02:00
Wim Taymans
f0bc0d068e link: avoid multiple concurrent negotiations
When multiple links are created at the same time for the same port, we
get into a race where multiple links will try to set a format
asynchronously and eventually break the links. Avoid this by marking the
port as busy for as long as an async format or buffer is pending and
avoid starting new link negotiation when one of the ports is busy.

This problem was observed when ardour6 tries to link all device capture
ports to its single monitor port.
2021-09-07 15:48:44 +02:00
Torkel Niklasson
eff67c3c03 Add log level argument to ratelimit_test function
If a log message is rate limited, we only need to know about it if we
are actually interested in that log level. We therefore add an argument
to the ratelimit_test function to set the log level of the message
printed if a message is skipped

Change-Id: I5ccd4a78bf7e972fe8b0e7133cd7e08c1e38835f
2021-08-12 18:59:31 +00:00
Wim Taymans
62f8ffcfb2 impl-link: put the peer_id in the mix
Place the global id of the peer port in the mix so that we can track
the peer object that way.
2021-08-03 17:33:49 +02:00
Wim Taymans
1ff208875c context: implement dynamic rate
Add a default.clock.allowed-rates property that lists the possible
rates for the graph.

Add node.rate and node.lock-rate properties to suggest a graph rate
and lock the rate.

Collect the largest clock rate from the nodes and if it is allowed,
try to configure it as the graph rate. Only switch rates when the
driver is IDLE or suspended or when we force a rate.

No alternative samplerates are specified because we first need to
work around a common driver bug (cards with 1 cristal need the same
rate for capture as playback) for this to work.
2021-07-30 16:15:34 +02:00
Wim Taymans
6acf72dc30 impl-node: rework quantum and max_quantum handling
Rework the quantum and max_quantum handling. Work directly with the
latency fractions and calculate the final quantum size until we know
the samplerate.
2021-07-30 11:42:15 +02:00
Wim Taymans
7bec96640c node: add node.lock-quantum property
The graph will not switch quantums when there is an active node
with the node.lock-quantum property set to true.

It can be used to stop certain jack clients from crashing when the
quantum changes.
2021-07-30 11:42:15 +02:00
Wim Taymans
08a1ca403f context: add option for soft/hard clock rate changes
Hard rate changes (the default now) makes the graph suspend so that the
driver reopens the device with the new sample rate if possible. This
causes a glitch.

Soft rate changes works as before and just changes the clock rate of
the position area, which makes everything resample things to the new
rate without a glitch.

Sample rate changes can currently still only be triggered by
configuring the settings metadata clock.force-rate
2021-07-29 17:13:54 +02:00
Wim Taymans
d1905716e4 impl-node: Split ALWAYS_PROCESS and WANT_DRIVER handling
Make a new PW_KEY_NODE_WANT_DRIVER to assign the node to a running
driver. (does not work yet)
Use a new variable to hold the ALWAYS_PROCESS setting and also
update want_driver.
This makes things it a bit more future proof.
2021-07-26 10:38:06 +02:00
Wim Taymans
33f90abfb5 impl-link: use loopvisited variable for loop checking
Don't reuse the visited variable for checking feedback loops because the
scheduler expects it to be false on entry. Use a different variable
instead.
2021-07-07 15:56:39 +02:00
Wim Taymans
5e0c9199bd context: drop RT when freewheeling
When we are freewheeling, drop the RT priority so that we don't
lock up the system too much.
2021-07-05 10:41:57 +02:00
Wim Taymans
27b9f469b5 impl-port: avoid recalculating latency on destroying port
Fixes a crash.

Fixes #1371
2021-06-30 09:36:36 +02:00
Peter Hutterer
0a5ae1cf47 pipewire: drop \memberof declarations
This is obsolete since the move to doxygen groups and having \memberof blocked
the documentation in the source file from being merged with the header file.
2021-06-21 07:17:35 +00:00
Wim Taymans
4518eded5b context: clean up the settings object as well 2021-06-18 15:26:20 +02:00
Wim Taymans
e301048abb settings: use metadata for settings
The settings metadata can be used to modify global context properties
at runtime such as min/max quantum, loglevel and samplerate.

See #1288
2021-06-17 11:13:42 +02:00
Wim Taymans
80ef77f994 context: add metadata implementation
Add a simple metadata implementation to the core that clients can
use to manage metadata or export.
2021-06-17 11:11:45 +02:00
Wim Taymans
d8ad87fd09 context: improve settings and defaults
Make structure with defaults that holds the defaults as they are loaded
from the config file or initialized with default values.

Copy this structure to a settings version that is used at runtime.

Add a force-quantum and force-rate field in the settings that can be
used to force a quantum and samplerate if != 0.
2021-06-17 11:11:45 +02:00
Wim Taymans
9984dcd1ea pipewire: small comment fix 2021-06-16 12:17:15 +02:00
Wim Taymans
c803444123 impl-port: only send latency param when supported
Check if the port has latency param and only try to set the
latency param when it appears available. This avoids sending unknown
latency params to an old client and erroring out.
2021-05-31 11:31:18 +02:00
Wim Taymans
cd58c51582 port: implement latency_changed event
Emit the latency changed event when the latency was updated.
2021-05-27 15:26:09 +02:00
Wim Taymans
b9b89b92b2 spa: add some latency helpers
Add more fields to the latency object.
Add methods to create, parse and process latency info.
2021-05-27 15:26:09 +02:00
Wim Taymans
cd32404e92 port: implement latency reporting some more
Implement a port recalculate latency method that takes the min
and max latency of all peer ports and sets that as the new port
latency.
When a link is made, let the output and input port recalculate
latencies.
Pass latency param in audioconvert.
2021-05-27 15:26:09 +02:00
Wim Taymans
efc497a38a spa: make a new FREEWHEEL clock flag
When freewheeling, the clock is going faster than real time.
When freewheeling, skip samples in alsa sink/source.
2021-05-07 09:03:34 +02:00
Wim Taymans
fab199d5b9 impl-node: make the group a string
We are currently using strings for the node group so actually store
this as a string or else all strings will end up in group 0.
2021-05-07 09:03:33 +02:00
Peter Hutterer
2405f0942b spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Andrea Gelmini
f489e32e44 Fix typo in code 2021-04-30 07:40:20 +00:00
Andrea Gelmini
47ef2b6b09 Fix typos 2021-04-30 07:40:20 +00:00
Wim Taymans
0a3d44ac53 context: add method to get a work_queue
Make a method to get a work-queue from the context. There is one
work-queue to use and the context will allocate it when requested
and free when destroyed.

The work queue is handy to delay execution of some logic for later,
either in the next iteration of the main-loop or when an async
operation completed.

Export some work-queue methods.
2021-04-21 12:17:53 +02:00
Wim Taymans
5f7910fcac impl-port: only add the port when buffers are negotiated
To avoid crashes when the node is scheduled but buffer have been
cleared.

See #904
2021-03-25 11:30:58 +01:00
Jonas Holmberg
44e0251afd impl-node: Make rounding of quantum configurable
Add new context config clock.power-of-two-quantum to make it possible to
not round quantum to closest lower power of two. This makes it possible
to match the quantum of a source node with the quantum of a client
node.
2021-03-16 19:09:29 +00:00
Wim Taymans
62def0399f impl-node: rework link activation
Only activate the links when the node is added to a driver. Otherwise
the driver will expect us to decrement the activation counters for the
links but that won't happen because the node will not be processed
yet.

Instead we activate the links that were not activated yet when the
node is activated.

This improves scheduling for newly added links and nodes.
2021-03-10 13:06:02 +01:00
Wim Taymans
c8804c3d6d context: make a new node.max-latency property
node.latency also influences the pipeline latency in that it can
push the latency above the default value.
node.max-latency, instead, is only used to clamp the final latency
of the pipeline.
2021-03-03 13:27:48 +01:00
Wim Taymans
c605672d43 Implement per client config files
Move the daemon config file loading to a new conf.c file used by
the context to load the configuration. This replaces the module
profiles and some hacks to move properties around.

If there is nothing other specified with $PIPEWIRE_CONFIG_NAME or
a property, the client.conf file is loaded as a fallback.

Update the session manager config file to load the modules via the
config now. Rename the session modules section to another name.

Update pipewire-pulse to also load a specific pulse property file.
This then makes it pssible to assign specific RT priorities for the
pipewire-pulse process.
2021-02-12 10:07:16 +01:00
Wim Taymans
210950dc0a context: disable mlock warnings by default
Make this a tunable option instead.
2021-02-08 10:59:02 +01:00
Wim Taymans
c25bdce645 rework param updates
Make it possible to add a NULL param to the pending list. The NULL
param removes all previous updates.
When applying the updates, the NULL param removes the params from
the target list.

For the cached params in the node/device/port we need to be careful
because multiple clients might ask for updates concurrently. Clear
the pending list whenever a new param update starts so that we always
only keep the last set of updates.

This has two advantages: it actually removes params that become
unreadable or that got removed and it allows us to update the target
list more efficiently in one single loop.
2021-02-05 11:03:47 +01:00
Wim Taymans
994fc1169e Revert "rework param updates"
This reverts commit 5aa7746c95.

Routes are duplicated for some reason, needs more debugging.
2021-02-04 20:56:54 +01:00
Wim Taymans
5aa7746c95 rework param updates
Make it possible to add a NULL param to the pending list. The NULL
param removes all previous updates.
When applying the updates, the NULL param removes the params from
the target list.

This has two advantages: it actually removes params that become
unreadable or that got removed and it allows us to update the target
list more efficiently in one single loop.
2021-02-04 13:26:35 +01:00
Wim Taymans
62954e14c3 node: improve profiler
Make a new complete event and use it instead of the start event
Use the start event at the start of the cycle
Make the profiler also log incomplete graph cycles
2020-12-20 20:37:21 +01:00
Wim Taymans
0370d7580f impl-node: save the original requested latency 2020-12-20 12:32:54 +01:00