diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bank.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -166,10 +166,14 @@ void xas_bank_entry_duration(xas_bank *bank, size_t entry_index, struct timeval *tv) { xas_bank_entry *entry = entry_by_index(bank, entry_index); - size_t count = entry->duration; - tv->tv_sec = count / bank->format.sample_rate; - tv->tv_usec = (count % bank->format.sample_rate) * 1000000; + size_t seconds = entry->duration / bank->format.sample_rate, + remainder = entry->duration % bank->format.sample_rate; + + double subseconds = (double)remainder / (double)bank->format.sample_rate; + + tv->tv_sec = (time_t)seconds; + tv->tv_usec = (suseconds_t)(subseconds * 1000000.0); } int xas_bank_player_set_entry(xas_bank_player *player, size_t entry) { |