mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
context: calculate target rate only when needed
Instead of calculating the target rate and overriding it in some conditions, calculate it only if it is necessary. This change also eliminates a set of conditional branches that have the same outcome, which causes clang-tidy to produce a bugprone-branch-clone warning.
This commit is contained in:
parent
5054b48c9d
commit
3f87741b27
1 changed files with 11 additions and 10 deletions
|
|
@ -1180,21 +1180,22 @@ again:
|
||||||
running = !n->passive;
|
running = !n->passive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate desired rate */
|
|
||||||
target_rate = def_rate;
|
|
||||||
if (rate.denom != 0 && rate.num == 1) {
|
|
||||||
if (rates_contains(rates, n_rates, rate.denom))
|
|
||||||
target_rate = rate.denom;
|
|
||||||
}
|
|
||||||
if (force_rate)
|
if (force_rate)
|
||||||
lock_rate = false;
|
lock_rate = false;
|
||||||
|
|
||||||
current_rate = n->current_rate.denom;
|
current_rate = n->current_rate.denom;
|
||||||
if (target_rate != current_rate && lock_rate)
|
if (lock_rate ||
|
||||||
target_rate = current_rate;
|
(!force_rate &&
|
||||||
else if (target_rate != current_rate && !force_rate &&
|
(n->info.state > PW_NODE_STATE_IDLE)))
|
||||||
(n->info.state > PW_NODE_STATE_IDLE))
|
|
||||||
target_rate = current_rate;
|
target_rate = current_rate;
|
||||||
|
else {
|
||||||
|
/* calculate desired rate */
|
||||||
|
target_rate = def_rate;
|
||||||
|
if (rate.denom != 0 && rate.num == 1) {
|
||||||
|
if (rates_contains(rates, n_rates, rate.denom))
|
||||||
|
target_rate = rate.denom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target_rate != current_rate) {
|
if (target_rate != current_rate) {
|
||||||
pw_log_info("(%s-%u) state:%s new rate:%u->%u",
|
pw_log_info("(%s-%u) state:%s new rate:%u->%u",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue