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.
This commit is contained in:
Wim Taymans 2021-07-30 10:18:38 +02:00
parent 9f2d6d6d28
commit 7bec96640c
4 changed files with 10 additions and 2 deletions

View file

@ -1112,7 +1112,7 @@ again:
/* assign final quantum and set state for followers and drivers */
spa_list_for_each(n, &context->driver_list, driver_link) {
bool running = false;
bool running = false, lock_quantum = false;
uint32_t quantum = 0;
if (!n->driving || n->exported)
@ -1121,6 +1121,8 @@ again:
/* collect quantum and count active nodes */
spa_list_for_each(s, &n->follower_list, follower_link) {
lock_quantum |= s->lock_quantum;
if (s->quantum_size > 0) {
if (quantum == 0 || s->quantum_size < quantum)
quantum = s->quantum_size;
@ -1147,7 +1149,7 @@ again:
n->rt.position->clock.rate = SPA_FRACTION(1, def_rate);
}
if (quantum != n->rt.position->clock.duration) {
if (quantum != n->rt.position->clock.duration && !lock_quantum) {
pw_log_info("(%s-%u) new quantum:%"PRIu64"->%u",
n->name, n->info.id,
n->rt.position->clock.duration,

View file

@ -914,6 +914,8 @@ static void check_properties(struct pw_impl_node *node)
}
}
}
str = pw_properties_get(node->properties, PW_KEY_NODE_LOCK_QUANTUM);
node->lock_quantum = str ? pw_properties_parse_bool(str) : false;
pw_log_debug(NAME" %p: driver:%d recalc:%s active:%d", node, node->driver,
recalc_reason, node->active);

View file

@ -155,6 +155,9 @@ extern "C" {
* a fraction. Ex: 128/48000 */
#define PW_KEY_NODE_MAX_LATENCY "node.max-latency" /**< the maximum supported latency of the
* node as a fraction. Ex: 1024/48000 */
#define PW_KEY_NODE_LOCK_QUANTUM "node.lock-quantum" /**< don't change quantum when this node
* is active */
#define PW_KEY_NODE_DONT_RECONNECT "node.dont-reconnect" /**< don't reconnect this node */
#define PW_KEY_NODE_ALWAYS_PROCESS "node.always-process" /**< process even when unlinked */
#define PW_KEY_NODE_WANT_DRIVER "node.want-driver" /**< the node wants to be grouped with a driver

View file

@ -677,6 +677,7 @@ struct pw_impl_node {
unsigned int freewheel:1; /**< if this is the freewheel driver */
unsigned int loopchecked:1; /**< for feedback loop checking */
unsigned int always_process:1; /**< this node wants to always be processing, even when idle */
unsigned int lock_quantum:1; /**< don't change graph quantum */
uint32_t port_user_data_size; /**< extra size for port user data */