From 70657d9e7bc8e8e138afc42c38152ea85a3f2487 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 28 Feb 2024 20:42:42 +0300 Subject: [PATCH] audio::Stream interface --- src/audio/audio.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/audio/audio.h b/src/audio/audio.h index 1076caf8..cbeca812 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -69,6 +69,29 @@ namespace audio { virtual uint getBitsPerSample() const=0; }; + /// @brief Audio streaming interface + class Stream { + public: + virtual ~Stream() {}; + + /// @brief Create new speaker bound to the Stream + /// and having high priority + /// @return speaker id or 0 + virtual speakerid_t createSpeaker() = 0; + + /// @brief Get id of the bound speaker + /// @return speaker id or 0 if no speaker bound + virtual speakerid_t getSpeaker() const = 0; + + /// @brief Update stream state (preload samples if needed) + /// @param delta time elapsed since the last update + virtual void update(double delta) = 0; + + /// @brief Set playhead to the selected time + /// @param time selected time + virtual void setTime(duration_t time) = 0; + }; + /// @brief Sound is an audio asset that supposed to support many /// simultaneously playing instances with different sources. /// So it's audio data is stored in memory. @@ -251,7 +274,7 @@ namespace audio { extern Speaker* get(speakerid_t id); /// @brief Update audio streams and sound instanced - /// @param delta time since the last update (seconds) + /// @param delta time elapsed since the last update (seconds) extern void update(double delta); /// @brief Finalize audio system