diff options
author | XANTRONIX Development | 2022-03-07 23:38:28 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-03-07 23:38:28 -0500 |
commit | c399e98203720cd42b11036d47ade56d95173c37 (patch) | |
tree | 4a355400529ab3856fefc304a6e1559c2064acbf /src | |
parent | 886a8f7a37fb58105b26e6ec640269b184f69a38 (diff) | |
download | xas-c399e98203720cd42b11036d47ade56d95173c37.tar.gz xas-c399e98203720cd42b11036d47ade56d95173c37.tar.bz2 xas-c399e98203720cd42b11036d47ade56d95173c37.zip |
Fix incorrect xas_bank_entry_duration()
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) { |