From 59fd8528d408f3abd22e32e3695649317ac5b5d8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 14 Mar 2019 15:21:03 -0700 Subject: [PATCH] Avoid division rounding errors w/ clock counts --- lib/src/parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/parser.c b/lib/src/parser.c index 15b33d54..7125faa9 100644 --- a/lib/src/parser.c +++ b/lib/src/parser.c @@ -1594,11 +1594,11 @@ void ts_parser_set_enabled(TSParser *self, bool enabled) { } uint64_t ts_parser_timeout_micros(const TSParser *self) { - return self->clock_limit / (get_clocks_per_second() / 1000000); + return self->clock_limit * 1000000 / get_clocks_per_second(); } void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros) { - self->clock_limit = timeout_micros * (get_clocks_per_second() / 1000000); + self->clock_limit = timeout_micros * get_clocks_per_second() / 1000000; if (self->clock_limit == 0) self->clock_limit = UINT64_MAX; }