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
This commit is contained in:
Wim Taymans 2021-12-15 10:45:48 +01:00
parent c903c2ca08
commit c97d489929
3 changed files with 9 additions and 2 deletions

View file

@ -1211,6 +1211,7 @@ again:
suspend_driver(context, n);
}
n->current_rate = SPA_FRACTION(1, target_rate);
n->current_pending = true;
current_rate = target_rate;
/* we might be suspended now and the links need to be prepared again */
goto again;
@ -1242,6 +1243,7 @@ again:
n->current_quantum,
quantum);
n->current_quantum = quantum;
n->current_pending = true;
}
pw_log_debug("%p: driving %p running:%d passive:%d quantum:%u '%s'",

View file

@ -820,6 +820,7 @@ int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driv
if (old != node && old->driving && driver->info.state < PW_NODE_STATE_RUNNING) {
driver->current_rate = old->current_rate;
driver->current_quantum = old->current_quantum;
driver->current_pending = true;
pw_log_info("move quantum:%"PRIu64" rate:%d (%s-%d -> %s-%d)",
driver->current_quantum,
driver->current_rate.denom,
@ -1592,8 +1593,11 @@ static int node_ready(void *data, int status)
node->rt.target.signal(node->rt.target.data);
}
node->rt.position->clock.duration = node->current_quantum;
node->rt.position->clock.rate = node->current_rate;
if (node->current_pending) {
node->rt.position->clock.duration = node->current_quantum;
node->rt.position->clock.rate = node->current_rate;
node->current_pending = false;
}
sync_type = check_updates(node, &reposition_owner);
owner[0] = ATOMIC_LOAD(a->segment_owner[0]);

View file

@ -684,6 +684,7 @@ struct pw_impl_node {
unsigned int lock_quantum:1; /**< don't change graph quantum */
unsigned int lock_rate:1; /**< don't change graph rate */
unsigned int transport_sync:1; /**< supports transport sync */
unsigned int current_pending:1; /**< a quantum/rate update is pending */
uint32_t port_user_data_size; /**< extra size for port user data */