context: avoid useless graph recalculations

Only recalculate the state of the graph when we actually managed to
suspend a driver node.
This commit is contained in:
Wim Taymans 2022-11-11 19:41:49 +01:00
parent 04aa803d7e
commit ea4e5cf364

View file

@ -1195,6 +1195,7 @@ again:
} }
if (target_rate != current_rate) { if (target_rate != current_rate) {
bool do_suspend = false;
/* we doing a rate switch */ /* we doing a rate switch */
pw_log_info("(%s-%u) state:%s new rate:%u->%u", pw_log_info("(%s-%u) state:%s new rate:%u->%u",
n->name, n->info.id, n->name, n->info.id,
@ -1204,17 +1205,20 @@ again:
if (force_rate) { if (force_rate) {
if (settings->clock_rate_update_mode == CLOCK_RATE_UPDATE_MODE_HARD) if (settings->clock_rate_update_mode == CLOCK_RATE_UPDATE_MODE_HARD)
suspend_driver(context, n); do_suspend = true;
} else { } else {
if (n->info.state >= PW_NODE_STATE_SUSPENDED) if (n->info.state >= PW_NODE_STATE_SUSPENDED)
suspend_driver(context, n); do_suspend = true;
} }
if (do_suspend)
suspend_driver(context, n);
/* we're setting the pending rate. This will become the new /* we're setting the pending rate. This will become the new
* current rate in the next iteration of the graph. */ * current rate in the next iteration of the graph. */
n->current_rate = SPA_FRACTION(1, target_rate); n->current_rate = SPA_FRACTION(1, target_rate);
n->current_pending = true; n->current_pending = true;
current_rate = target_rate; current_rate = target_rate;
/* we might be suspended now and the links need to be prepared again */ /* we might be suspended now and the links need to be prepared again */
if (do_suspend)
goto again; goto again;
} }