13
0

fix potential for overflow when converting larger sample counts to superclock.

int_div_rount<T> was using int (32 bits) which could overflow.
This commit is contained in:
Paul Davis 2020-12-01 22:28:39 -07:00
parent 15b28b103a
commit b01b6929fb

View File

@ -30,7 +30,7 @@ typedef int64_t superclock_t;
extern superclock_t superclock_ticks_per_second;
static inline superclock_t superclock_to_samples (superclock_t s, int sr) { return int_div_round (s * sr, superclock_ticks_per_second); }
static inline superclock_t samples_to_superclock (int samples, int sr) { return int_div_round (samples * superclock_ticks_per_second, superclock_t (sr)); }
static inline superclock_t samples_to_superclock (int64_t samples, int sr) { return int_div_round (samples * superclock_ticks_per_second, superclock_t (sr)); }
/* this needs to be updated per-thread at a suitable time */