aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SoundContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade/SoundContext.cpp')
-rw-r--r--src/crepe/facade/SoundContext.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/crepe/facade/SoundContext.cpp b/src/crepe/facade/SoundContext.cpp
index 8bd7e74..d18afc6 100644
--- a/src/crepe/facade/SoundContext.cpp
+++ b/src/crepe/facade/SoundContext.cpp
@@ -15,18 +15,23 @@ SoundContext::~SoundContext() {
this->engine.deinit();
}
-Sound::Handle SoundContext::play(Sound & resource) {
- return {
- .handle = this->engine.play(resource.sample, 1.0f),
- };
+SoundHandle SoundContext::play(Sound & resource) {
+ SoLoud::handle real_handle = this->engine.play(resource.sample, 1.0f);
+ SoundHandle handle = this->next_handle;
+ this->registry[handle] = real_handle;
+ this->next_handle++;
+ return handle;
}
-void SoundContext::stop(Sound::Handle & handle) { this->engine.stop(handle.handle); }
+void SoundContext::stop(const SoundHandle & handle) {
+ this->engine.stop(this->registry[handle]);
+}
-void SoundContext::set_volume(Sound::Handle & handle, float volume) {
- this->engine.setVolume(handle.handle, volume);
+void SoundContext::set_volume(const SoundHandle & handle, float volume) {
+ this->engine.setVolume(this->registry[handle], volume);
}
-void SoundContext::set_loop(Sound::Handle & handle, bool loop) {
- this->engine.setLooping(handle.handle, loop);
+void SoundContext::set_loop(const SoundHandle & handle, bool loop) {
+ this->engine.setLooping(this->registry[handle], loop);
}
+