alsa: do resync based on current measurements

Call update time with the currently measured delay and then resync when
needed. Previously we would do the resync in the next cycle.

See #2257
This commit is contained in:
Wim Taymans 2022-05-27 21:20:51 +02:00
parent 3e7f975f83
commit 63d2102594

View file

@ -1902,6 +1902,9 @@ int spa_alsa_write(struct state *state)
if (SPA_UNLIKELY((res = get_status(state, current_time, &delay, &target)) < 0))
return res;
if (SPA_UNLIKELY((res = update_time(state, current_time, delay, target, true)) < 0))
return res;
if (SPA_UNLIKELY(state->alsa_sync)) {
if (SPA_UNLIKELY(state->alsa_sync_warning)) {
spa_log_warn(state->log, "%s: follower delay:%ld target:%ld thr:%u, resync",
@ -1918,8 +1921,6 @@ int spa_alsa_write(struct state *state)
delay = target;
state->alsa_sync = false;
}
if (SPA_UNLIKELY((res = update_time(state, current_time, delay, target, true)) < 0))
return res;
}
total_written = 0;
@ -2146,6 +2147,9 @@ int spa_alsa_read(struct state *state)
avail = delay;
if (SPA_UNLIKELY((res = update_time(state, current_time, delay, target, true)) < 0))
return res;
if (state->alsa_sync) {
if (SPA_UNLIKELY(state->alsa_sync_warning)) {
spa_log_warn(state->log, "%s: follower delay:%lu target:%lu thr:%u, resync",
@ -2163,9 +2167,6 @@ int spa_alsa_read(struct state *state)
state->alsa_sync = false;
}
if ((res = update_time(state, current_time, delay, target, true)) < 0)
return res;
if (avail < state->read_size)
max_read = 0;
}