From ac0defb30297d38a032104ae3c953a5d3c5ada60 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 7 Mar 2022 20:49:46 -0500 Subject: xas_bank_entry_duration(): use struct timeval --- include/xas/bank.h | 5 ++++- src/bank.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/xas/bank.h b/include/xas/bank.h index 7828587..77a2620 100644 --- a/include/xas/bank.h +++ b/include/xas/bank.h @@ -2,6 +2,7 @@ #define _XAS_BANK_H #include +#include #include #include @@ -46,7 +47,9 @@ xas_bank *xas_bank_new(xas_audio_format format, void xas_bank_destroy(xas_bank *bank); -size_t xas_bank_entry_duration(xas_bank *bank, size_t entry_index); +void xas_bank_entry_duration(xas_bank *bank, + size_t entry_index, + struct timeval *tv); ssize_t xas_bank_record(xas_bank *bank, xas_audio_stream *input, diff --git a/src/bank.c b/src/bank.c index 698cbfb..53f1a61 100644 --- a/src/bank.c +++ b/src/bank.c @@ -162,10 +162,14 @@ void xas_bank_player_destroy(xas_bank_player *player) { free(player); } -size_t xas_bank_entry_duration(xas_bank *bank, size_t entry_index) { +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; - return entry->duration; + tv->tv_sec = count / bank->format.sample_rate; + tv->tv_usec = (count % bank->format.sample_rate) * 1000000; } int xas_bank_player_set_entry(xas_bank_player *player, size_t entry) { -- cgit v1.2.3