summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/xas/bank.h6
-rw-r--r--src/bank.c13
2 files changed, 18 insertions, 1 deletions
diff --git a/include/xas/bank.h b/include/xas/bank.h
index aed01ab..716ad64 100644
--- a/include/xas/bank.h
+++ b/include/xas/bank.h
@@ -8,6 +8,9 @@
#define XAS_BANK_PLAYER_DEFAULT_GAIN 1.0f
+#define XAS_BANK_PLAYER_NONE 0
+#define XAS_BANK_PLAYER_LOOP (1 << 0)
+
enum xas_bank_player_status {
XAS_BANK_PLAYER_STOPPED,
XAS_BANK_PLAYER_PLAYING,
@@ -29,6 +32,7 @@ typedef struct _xas_bank_player {
xas_bank *bank;
enum xas_bank_player_status status;
+ int flags;
float gain;
@@ -63,6 +67,8 @@ int xas_bank_player_start(xas_bank_player *player);
int xas_bank_player_stop(xas_bank_player *player);
+int xas_bank_player_set_flags(xas_bank_player *player, int flags);
+
int xas_bank_player_playing(xas_bank_player *player);
xas_audio_stream *xas_bank_player_stream_new(xas_bank_player *player);
diff --git a/src/bank.c b/src/bank.c
index b7a3f0a..20a4569 100644
--- a/src/bank.c
+++ b/src/bank.c
@@ -140,6 +140,7 @@ xas_bank_player *xas_bank_player_new(xas_bank *bank) {
player->bank = bank;
player->status = XAS_BANK_PLAYER_STOPPED;
player->gain = XAS_BANK_PLAYER_DEFAULT_GAIN;
+ player->flags = XAS_BANK_PLAYER_NONE;
player->entry = 0;
player->index = 0;
@@ -195,6 +196,12 @@ int xas_bank_player_stop(xas_bank_player *player) {
return 0;
}
+int xas_bank_player_set_flags(xas_bank_player *player, int flags) {
+ player->flags = flags;
+
+ return 0;
+}
+
int xas_bank_player_playing(xas_bank_player *player) {
return player->status == XAS_BANK_PLAYER_PLAYING;
}
@@ -229,7 +236,11 @@ static ssize_t stream_fill(xas_bank_player *player,
index_o += amount;
if (player->index == entry->duration) {
- xas_bank_player_stop(player);
+ if (player->flags & XAS_BANK_PLAYER_LOOP) {
+ player->index = 0;
+ } else {
+ xas_bank_player_stop(player);
+ }
}
} else {
xas_audio_zero(bank->format, dest, index_o, left);