From 1bbb144b59e8e3fc38f28ed68de47aaeb2849228 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 30 Aug 2019 17:32:56 +0200 Subject: [PATCH] alsa-utils: update the threshold also for capture --- spa/plugins/alsa/alsa-utils.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index ec6d1811b..80c995ee0 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -885,22 +885,23 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence) snd_pcm_uframes_t read, frames, offset; int res; - if (state->position && !state->slaved) { - uint64_t position, duration; + if (state->position) { + if (state->duration != state->position->clock.duration) { + state->duration = state->position->clock.duration; + state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom; + } + if (!state->slaved) { + uint64_t position; - duration = state->position->clock.duration; - if (state->duration != duration) { - state->duration = duration; - state->threshold = (duration * state->rate + state->rate_denom-1) / state->rate_denom; + position = state->position->clock.position; + if (state->last_position && state->last_position + state->last_duration != position) { + state->alsa_sync = true; + spa_log_warn(state->log, "discont, resync %"PRIu64" %"PRIu64" %d", + state->last_position, position, state->last_duration); + } + state->last_position = position; + state->last_duration = state->duration; } - position = state->position->clock.position; - if (state->last_position && state->last_position + state->last_duration != position) { - state->alsa_sync = true; - spa_log_warn(state->log, "discont, resync %"PRIu64" %"PRIu64" %d", - state->last_position, position, state->last_duration); - } - state->last_position = position; - state->last_duration = duration; } if (state->slaved && state->alsa_started) {