use round() for rounding

Replace casting of values incremented by +0.5/-0.5 with round().
This commit is contained in:
Miroslav Lichvar
2021-09-23 10:01:50 +02:00
parent 9600993c28
commit d0d9a3fa43
4 changed files with 4 additions and 22 deletions

View File

@@ -572,10 +572,7 @@ RCL_AddCookedPulse(RCL_Instance instance, struct timespec *cooked_time,
}
/* Align the offset to the reference sample */
if ((ref_sample.offset - offset) >= 0.0)
shift = (long)((ref_sample.offset - offset) * rate + 0.5) / (double)rate;
else
shift = (long)((ref_sample.offset - offset) * rate - 0.5) / (double)rate;
shift = round((ref_sample.offset - offset) * rate) / rate;
offset += shift;