From 2658b941c4f7c20025b27d013fd7e7fbe8e176de Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Sun, 12 Nov 2023 15:10:40 +0000 Subject: [PATCH] IMixer add reset channel group (stop) --- .../src/HyperSonicDrivers/audio/IMixer.hpp | 1 + .../src/HyperSonicDrivers/audio/sdl2/Mixer.cpp | 11 +++++++++++ .../src/HyperSonicDrivers/audio/sdl2/Mixer.hpp | 1 + .../test/HyperSonicDrivers/audio/IMixerMock.hpp | 1 + 4 files changed, 14 insertions(+) diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IMixer.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IMixer.hpp index 78093ca8..4f1988b0 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IMixer.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IMixer.hpp @@ -45,6 +45,7 @@ namespace HyperSonicDrivers::audio virtual void reset() noexcept = 0; virtual void reset(const uint8_t id) noexcept = 0; + virtual void reset(const mixer::eChannelGroup group) noexcept = 0; virtual void pause() noexcept = 0; virtual void pause(const uint8_t id) noexcept = 0; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp index 0697c99c..f6d98ca0 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp @@ -86,6 +86,17 @@ namespace HyperSonicDrivers::audio::sdl2 m_channels[id]->reset(); } + void Mixer::reset(const mixer::eChannelGroup group) noexcept + { + std::scoped_lock lck(m_mutex); + + for (const auto& ch : m_channels) + { + if (ch->getChannelGroup() == group) + ch->reset(); + } + } + void Mixer::pause() noexcept { std::scoped_lock lck(m_mutex); diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.hpp index bfaaa2a7..e8693568 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.hpp @@ -32,6 +32,7 @@ namespace HyperSonicDrivers::audio::sdl2 void reset() noexcept override; void reset(const uint8_t id) noexcept override; + void reset(const mixer::eChannelGroup group) noexcept override; void pause() noexcept override; void pause(const uint8_t id) noexcept override; diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp index cb1c07c4..25f13482 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp @@ -33,6 +33,7 @@ namespace HyperSonicDrivers::audio void reset() noexcept override {}; void reset(const uint8_t id) noexcept override {}; + void reset(const mixer::eChannelGroup group) noexcept override {}; void pause() noexcept override {}; void pause(const uint8_t id) noexcept override {};