diff options
author | XANTRONIX Development | 2022-02-23 00:21:38 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-23 00:21:38 -0500 |
commit | 52b99333c5e8cf3b757cd6e88fca13d420b54979 (patch) | |
tree | 9b231c40eb4bd7d53ce07cedb50f8a40c589d2d7 /include/xas | |
parent | fc378a22b3294bcb696b8600e6fd8f9f639c36fc (diff) | |
download | xas-52b99333c5e8cf3b757cd6e88fca13d420b54979.tar.gz xas-52b99333c5e8cf3b757cd6e88fca13d420b54979.tar.bz2 xas-52b99333c5e8cf3b757cd6e88fca13d420b54979.zip |
Implement xas_bank_player type
Changes:
* Implement xas_bank_player type to decouple player state from
sample storage, to allow multiple concurrent players against a
single sample bank
* Refactor examples/say.c to use xas_bank_player
Diffstat (limited to 'include/xas')
-rw-r--r-- | include/xas/bank.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/include/xas/bank.h b/include/xas/bank.h index 9f877d0..be623f0 100644 --- a/include/xas/bank.h +++ b/include/xas/bank.h @@ -5,8 +5,10 @@ #include <xas/audio.h> -#define XAS_BANK_IDLE 0 -#define XAS_BANK_ACTIVE (1 << 0) +enum xas_bank_player_status { + XAS_BANK_PLAYER_STOPPED, + XAS_BANK_PLAYER_PLAYING, +}; typedef struct _xas_bank_entry { size_t duration; @@ -17,13 +19,17 @@ typedef struct _xas_bank { size_t entry_size, entry_count; +} xas_bank; + +typedef struct _xas_bank_player { + xas_bank *bank; + enum xas_bank_player_status status; - int flags; float gain; size_t entry, index; -} xas_bank; +} xas_bank_player; xas_bank *xas_bank_new(xas_audio_format format, size_t entry_size, @@ -31,17 +37,23 @@ xas_bank *xas_bank_new(xas_audio_format format, void xas_bank_destroy(xas_bank *bank); -int xas_bank_play(xas_bank *bank, size_t entry, float gain); - -void xas_bank_stop(xas_bank *bank); - -int xas_bank_active(xas_bank *bank); - ssize_t xas_bank_record(xas_bank *bank, xas_audio_stream *input, size_t entry_index, size_t count); -xas_audio_stream *xas_bank_stream_new(xas_bank *bank); +xas_bank_player *xas_bank_player_new(xas_bank *bank); + +void xas_bank_player_destroy(xas_bank_player *player); + +int xas_bank_player_start(xas_bank_player *player, + size_t entry, + float gain); + +int xas_bank_player_stop(xas_bank_player *player); + +int xas_bank_player_playing(xas_bank_player *player); + +xas_audio_stream *xas_bank_player_stream_new(xas_bank_player *player); #endif /* _XAS_BANK_H */ |