From: Keith Packard Date: Mon, 7 Sep 2009 04:01:44 +0000 (-0700) Subject: Fix cc_period_make to not get stuck on samples with matching time X-Git-Tag: debian/0.5+77+gc57bd7f~8^2~2 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=9e660315e1bd2bf71ab1c0574e895e1f7608a58f;ds=sidebyside Fix cc_period_make to not get stuck on samples with matching time When two samples have matching times, step to the second one; otherwise, we'll get stuck forever. Signed-off-by: Keith Packard --- diff --git a/ao-tools/lib/cc-period.c b/ao-tools/lib/cc-period.c index 2a4e5952..844ac79e 100644 --- a/ao-tools/lib/cc-period.c +++ b/ao-tools/lib/cc-period.c @@ -35,7 +35,7 @@ cc_period_make(struct cc_timedata *td, double start_time, double stop_time) j = 0; for (i = 0; i < pd->num; i++) { t = start_time + i * pd->step; - while (j < td->num - 1 && fabs(t - td->data[j].time) > fabs(t - td->data[j+1].time)) + while (j < td->num - 1 && fabs(t - td->data[j].time) >= fabs(t - td->data[j+1].time)) j++; pd->data[i] = td->data[j].value; }