summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-07 23:38:28 -0500
committerXANTRONIX Development2022-03-07 23:38:28 -0500
commitc399e98203720cd42b11036d47ade56d95173c37 (patch)
tree4a355400529ab3856fefc304a6e1559c2064acbf /src
parent886a8f7a37fb58105b26e6ec640269b184f69a38 (diff)
downloadxas-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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/bank.c b/src/bank.c
index 1759a54..d9b85bb 100644
--- a/src/bank.c
+++ b/src/bank.c
@@ -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) {