samplefilt: drop last sample in SPF_DropSamples()
When SPF_DropSamples() is called, don't keep the last sample to be retrieved by SPF_GetLastSample(). It should be kept only after filtering.
This commit is contained in:
parent
35220aac9d
commit
e66f1df89d
2 changed files with 14 additions and 3 deletions
16
samplefilt.c
16
samplefilt.c
|
@ -170,11 +170,21 @@ SPF_GetAvgSampleDispersion(SPF_Instance filter)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SPF_DropSamples(SPF_Instance filter)
|
||||
static void
|
||||
drop_samples(SPF_Instance filter, int keep_last)
|
||||
{
|
||||
filter->index = -1;
|
||||
filter->used = 0;
|
||||
if (!keep_last)
|
||||
filter->last = -1;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SPF_DropSamples(SPF_Instance filter)
|
||||
{
|
||||
drop_samples(filter, 0);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -405,7 +415,7 @@ SPF_GetFilteredSample(SPF_Instance filter, NTP_Sample *sample)
|
|||
if (!combine_selected_samples(filter, n, sample))
|
||||
return 0;
|
||||
|
||||
SPF_DropSamples(filter);
|
||||
drop_samples(filter, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ test_unit(void)
|
|||
|
||||
} else {
|
||||
SPF_DropSamples(filter);
|
||||
TEST_CHECK(filter->last < 0);
|
||||
}
|
||||
|
||||
TEST_CHECK(SPF_GetNumberOfSamples(filter) == 0);
|
||||
|
|
Loading…
Reference in a new issue