mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: separate max_error and max_resync
Use a separate variable to hold the maximum amount of drift we allow between driver and follower. Ensure this value is smaller than the max_error and period size so that we have at most 1 period of drift.
This commit is contained in:
parent
30657abf28
commit
261fb64849
2 changed files with 8 additions and 4 deletions
|
|
@ -1969,12 +1969,14 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
|
|||
state->alsa_sync = true;
|
||||
state->alsa_sync_warning = false;
|
||||
}
|
||||
if (err > state->max_error) {
|
||||
err = state->max_error;
|
||||
if (err > state->max_resync) {
|
||||
state->alsa_sync = true;
|
||||
} else if (err < -state->max_error) {
|
||||
err = -state->max_error;
|
||||
if (err > state->max_error)
|
||||
err = state->max_error;
|
||||
} else if (err < -state->max_resync) {
|
||||
state->alsa_sync = true;
|
||||
if (err < -state->max_error)
|
||||
err = -state->max_error;
|
||||
}
|
||||
|
||||
if (!follower || state->matching)
|
||||
|
|
@ -2079,6 +2081,7 @@ static inline int check_position_config(struct state *state)
|
|||
return -EIO;
|
||||
state->threshold = SPA_SCALE32_UP(state->duration, state->rate, state->rate_denom);
|
||||
state->max_error = SPA_MAX(256.0f, state->threshold / 2.0f);
|
||||
state->max_resync = SPA_MIN(state->threshold, state->max_error);
|
||||
state->resample = ((uint32_t)state->rate != state->rate_denom) || state->matching;
|
||||
state->alsa_sync = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ struct state {
|
|||
|
||||
struct spa_dll dll;
|
||||
double max_error;
|
||||
double max_resync;
|
||||
|
||||
struct spa_latency_info latency[2];
|
||||
struct spa_process_latency_info process_latency;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue