summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bank.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/bank.c b/src/bank.c
index 20a4569..d2c7de9 100644
--- a/src/bank.c
+++ b/src/bank.c
@@ -40,11 +40,19 @@ void xas_bank_destroy(xas_bank *bank) {
free(bank);
}
+static inline xas_bank_entry *entry_by_index(xas_bank *bank,
+ size_t index) {
+ size_t size = sizeof(xas_bank_entry) + sizeof(int16_t) * bank->entry_size,
+ offset = size * index;
+
+ return (xas_bank_entry *)(((uint8_t *)(bank + 1)) + offset);
+}
+
ssize_t xas_bank_record(xas_bank *bank,
xas_audio_stream *input,
size_t entry_index,
size_t count) {
- xas_bank_entry *entry = &((xas_bank_entry *)(bank + 1))[entry_index];
+ xas_bank_entry *entry = entry_by_index(bank, entry_index);
size_t left = count,
index_o = 0;
@@ -217,8 +225,7 @@ static ssize_t stream_fill(xas_bank_player *player,
while (left) {
if (player->status == XAS_BANK_PLAYER_PLAYING) {
- xas_bank_entry *entry =
- &((xas_bank_entry *)(bank + 1))[player->entry];
+ xas_bank_entry *entry = entry_by_index(bank, player->entry);
int16_t *src = (int16_t *)(entry + 1);