From 9e660315e1bd2bf71ab1c0574e895e1f7608a58f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 6 Sep 2009 21:01:44 -0700 Subject: [PATCH] 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 --- ao-tools/lib/cc-period.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.30.2