From 2d5d8a039518ec5901148f7c2d186f48af542079 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 8 Apr 2017 20:36:24 +0200 Subject: [PATCH] tsproc: Allow clock synchronization immediately after jump. After a servo jump, the call to tsproc_reset() clears tsp->t3. This causes the next call to tsproc_update_offset() to fail. However the offset calculation does not necessarily depend on t3, i.e. when filtered_delay is available and neither raw nor weighting is used. This patch fixes the issue by allowing the stored filtered delay to be used when appropriate. Signed-off-by: Richard Cochran Reported-by: Burkhard Ilsen --- tsproc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tsproc.c b/tsproc.c index 550f32c..63c989d 100644 --- a/tsproc.c +++ b/tsproc.c @@ -180,20 +180,28 @@ int tsproc_update_offset(struct tsproc *tsp, tmv_t *offset, double *weight) { tmv_t delay = 0, raw_delay = 0; - if (tmv_is_zero(tsp->t1) || tmv_is_zero(tsp->t2) || - tmv_is_zero(tsp->t3)) + if (tmv_is_zero(tsp->t1) || tmv_is_zero(tsp->t2)) return -1; switch (tsp->mode) { case TSPROC_FILTER: + if (!tsp->filtered_delay_valid) { + return -1; + } delay = tsp->filtered_delay; break; case TSPROC_RAW: case TSPROC_RAW_WEIGHT: + if (tmv_is_zero(tsp->t3)) { + return -1; + } raw_delay = get_raw_delay(tsp); delay = raw_delay; break; case TSPROC_FILTER_WEIGHT: + if (tmv_is_zero(tsp->t3) || !tsp->filtered_delay_valid) { + return -1; + } raw_delay = get_raw_delay(tsp); delay = tsp->filtered_delay; break;