alsa-utils: update the threshold also for capture

This commit is contained in:
Wim Taymans 2019-08-30 17:32:56 +02:00
parent 0f9594e119
commit 1bbb144b59

View file

@ -885,14 +885,14 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
snd_pcm_uframes_t read, frames, offset; snd_pcm_uframes_t read, frames, offset;
int res; int res;
if (state->position && !state->slaved) { if (state->position) {
uint64_t position, duration; if (state->duration != state->position->clock.duration) {
state->duration = state->position->clock.duration;
duration = state->position->clock.duration; state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
if (state->duration != duration) {
state->duration = duration;
state->threshold = (duration * state->rate + state->rate_denom-1) / state->rate_denom;
} }
if (!state->slaved) {
uint64_t position;
position = state->position->clock.position; position = state->position->clock.position;
if (state->last_position && state->last_position + state->last_duration != position) { if (state->last_position && state->last_position + state->last_duration != position) {
state->alsa_sync = true; state->alsa_sync = true;
@ -900,7 +900,8 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
state->last_position, position, state->last_duration); state->last_position, position, state->last_duration);
} }
state->last_position = position; state->last_position = position;
state->last_duration = duration; state->last_duration = state->duration;
}
} }
if (state->slaved && state->alsa_started) { if (state->slaved && state->alsa_started) {