refclock: trim offset in local mode

With the local option, trim offset larger than 1 second to not lose
precision after large steps of the clock.
This commit is contained in:
Miroslav Lichvar 2022-02-24 08:45:10 +01:00
parent d5e645eb38
commit 55717c1ccd

View file

@ -757,6 +757,12 @@ follow_local(RCL_Instance inst, struct timespec *prev_ref_time, double prev_freq
LCL_ReadCookedTime(&now, NULL); LCL_ReadCookedTime(&now, NULL);
SST_SlewSamples(stats, &now, dfreq, doffset); SST_SlewSamples(stats, &now, dfreq, doffset);
SPF_SlewSamples(inst->filter, &now, dfreq, doffset); SPF_SlewSamples(inst->filter, &now, dfreq, doffset);
/* Keep the offset close to zero to not lose precision */
if (fabs(offset) >= 1.0) {
SST_CorrectOffset(stats, -round(offset));
SPF_CorrectOffset(inst->filter, -round(offset));
}
} }
static void static void