Fix cc_period_make to not get stuck on samples with matching time
authorKeith Packard <keithp@keithp.com>
Mon, 7 Sep 2009 04:01:44 +0000 (21:01 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 7 Sep 2009 04:01:44 +0000 (21:01 -0700)
When two samples have matching times, step to the second one;
otherwise, we'll get stuck forever.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/lib/cc-period.c

index 2a4e59521907a36d621199c2e1a6a6e19d5f8072..844ac79e9fd35c9333a3053a177b8531719e1116 100644 (file)
@@ -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;
        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;
        }
                        j++;
                pd->data[i] = td->data[j].value;
        }