diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IAudioStream.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IAudioStream.hpp index ac822e05..2c922398 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IAudioStream.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IAudioStream.hpp @@ -23,5 +23,6 @@ namespace HyperSonicDrivers::audio virtual uint32_t getRate() const = 0; virtual bool endOfData() const = 0; virtual bool isEnded() const { return endOfData(); } + //virtual void forward(const uint32_t ms) = 0; }; } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.cpp index 343b59c0..78e4c358 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.cpp @@ -38,6 +38,12 @@ namespace HyperSonicDrivers::audio::streams return m_curPos == m_sound->dataSize; } + void PCMStream::forward(const uint32_t bytes) noexcept + { + m_curPos += bytes; + m_curPos = std::min(m_curPos, m_sound->dataSize); + } + std::shared_ptr PCMStream::getSound() const noexcept { return m_sound; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.hpp index 9c8901f4..fe22db6a 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/streams/PCMStream.hpp @@ -18,6 +18,7 @@ namespace HyperSonicDrivers::audio::streams uint32_t getRate() const override; bool endOfData() const override; + void forward(const uint32_t bytes) noexcept; std::shared_ptr getSound() const noexcept; private: std::shared_ptr m_sound; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.cpp index 37110ddc..6fb2f13d 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace HyperSonicDrivers::drivers { @@ -98,6 +99,12 @@ namespace HyperSonicDrivers::drivers releaseStreams_(); } + void PCMDriver::forward(const uint32_t ms) noexcept + { + for (const auto& [stream, _] : m_PCMStreams_channels) + stream->forward(utils::ms_toPos(ms, stream->getSound())); + } + void PCMDriver::releaseEndedStreams_() noexcept { for (auto it = m_PCMStreams_channels.begin(); it != m_PCMStreams_channels.end();) diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.hpp index 0bcb4820..0d4fe1ec 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/PCMDriver.hpp @@ -34,6 +34,8 @@ namespace HyperSonicDrivers::drivers void stop(const std::shared_ptr& sound, const bool releaseEndedStreams = true); void stop() noexcept; + void forward(const uint32_t ms) noexcept; + const uint8_t max_streams; private: std::shared_ptr m_mixer;