alsa: fix timeout adjustment

Only adjust the timeout when the quantum increases so that we end u
with exactly the number of samples of the new quantum.

Suppose we are handling a quantum of 1024, we wake up with 1024
samples in the device, we now notice a quantum of 8192 and will pull
in the 8192 samples, we then have 1024 + 8192 samples in the buffer.
Schedule a timeout for 1024 samples so that we end up in the timout
with 8192 samples in the device.
This commit is contained in:
Wim Taymans 2021-03-03 16:55:40 +01:00
parent 052bc85dad
commit 3bcc59120a

View file

@ -874,7 +874,8 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
int32_t diff = (int32_t) (state->last_threshold - state->threshold);
spa_log_trace(state->log, NAME" %p: follower:%d quantum change %d -> %d (%d)",
state, follower, state->last_threshold, state->threshold, diff);
state->next_time += diff / corr * 1e9 / state->rate;
if (diff < 0)
state->next_time += diff / corr * 1e9 / state->rate;
state->last_threshold = state->threshold;
}