From 0aca605bfb108bc91f0bdfced589e3365d07746b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 24 Sep 2018 10:36:53 +0200 Subject: [PATCH] alsa: init variable correctly We need to initialize the frames variable correctly before calling mmap. Also initialize the now timer when starting. --- spa/plugins/alsa/alsa-utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 20869d216..67dbf98dc 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -430,14 +430,14 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence) { snd_pcm_t *hndl = state->hndl; const snd_pcm_channel_area_t *my_areas; - snd_pcm_uframes_t written, frames, offset, off, to_write; + snd_pcm_uframes_t written, frames = state->buffer_frames, offset, off, to_write; int res; if ((res = snd_pcm_mmap_begin(hndl, &my_areas, &offset, &frames)) < 0) { spa_log_error(state->log, "snd_pcm_mmap_begin error: %s", snd_strerror(res)); return res; } - spa_log_trace(state->log, "begin %ld %ld", offset, frames); + spa_log_trace(state->log, "begin %ld %ld %d", offset, frames, state->threshold); silence = SPA_MIN(silence, frames); to_write = frames; @@ -787,6 +787,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover) state->alsa_started = true; } + clock_gettime(CLOCK_MONOTONIC, &state->now); ts.it_value.tv_sec = 0; ts.it_value.tv_nsec = 1; ts.it_interval.tv_sec = 0;