From 8e67adc6828181b1df7c95da76f32962444fc7fd Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 1 Oct 2024 17:25:06 +0200 Subject: rename SoundSystem to SoundContext (2/2) --- src/crepe/CMakeLists.txt | 4 ++-- src/crepe/Sound.cpp | 36 ++++++++++++++++++------------------ src/crepe/SoundContext.cpp | 10 +++++----- src/crepe/SoundContext.h | 16 ++++++++-------- 4 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt index 9f7c91c..3a60840 100644 --- a/src/crepe/CMakeLists.txt +++ b/src/crepe/CMakeLists.txt @@ -1,11 +1,11 @@ target_sources(crepe PUBLIC Sound.cpp - SoundSystem.cpp + SoundContext.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES Sound.h - SoundSystem.h + SoundContext.h ) add_subdirectory(api) diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp index 20f1787..1758282 100644 --- a/src/crepe/Sound.cpp +++ b/src/crepe/Sound.cpp @@ -1,7 +1,7 @@ #include "util/log.h" #include "Sound.h" -#include "SoundSystem.h" +#include "SoundContext.h" using namespace crepe; @@ -20,42 +20,42 @@ void Sound::load(std::unique_ptr res) { } void Sound::play() { - SoundSystem & system = SoundSystem::get_instance(); - if (system.engine.getPause(this->handle)) { + SoundContext & ctx = SoundContext::get_instance(); + if (ctx.engine.getPause(this->handle)) { // resume if paused - system.engine.setPause(this->handle, false); + ctx.engine.setPause(this->handle, false); } else { // or start new sound - this->handle = system.engine.play(this->sample, this->volume); - system.engine.setLooping(this->handle, this->looping); + this->handle = ctx.engine.play(this->sample, this->volume); + ctx.engine.setLooping(this->handle, this->looping); } } void Sound::pause() { - SoundSystem & system = SoundSystem::get_instance(); - if (system.engine.getPause(this->handle)) return; - system.engine.setPause(this->handle, true); + SoundContext & ctx = SoundContext::get_instance(); + if (ctx.engine.getPause(this->handle)) return; + ctx.engine.setPause(this->handle, true); } void Sound::rewind() { - SoundSystem & system = SoundSystem::get_instance(); - if (!system.engine.isValidVoiceHandle(this->handle)) return; - system.engine.seek(this->handle, 0); + SoundContext & ctx = SoundContext::get_instance(); + if (!ctx.engine.isValidVoiceHandle(this->handle)) return; + ctx.engine.seek(this->handle, 0); } void Sound::set_volume(float volume) { this->volume = volume; - SoundSystem & system = SoundSystem::get_instance(); - if (!system.engine.isValidVoiceHandle(this->handle)) return; - system.engine.setVolume(this->handle, this->volume); + SoundContext & ctx = SoundContext::get_instance(); + if (!ctx.engine.isValidVoiceHandle(this->handle)) return; + ctx.engine.setVolume(this->handle, this->volume); } void Sound::set_looping(bool looping) { this->looping = looping; - SoundSystem & system = SoundSystem::get_instance(); - if (!system.engine.isValidVoiceHandle(this->handle)) return; - system.engine.setLooping(this->handle, this->looping); + SoundContext & ctx = SoundContext::get_instance(); + if (!ctx.engine.isValidVoiceHandle(this->handle)) return; + ctx.engine.setLooping(this->handle, this->looping); } diff --git a/src/crepe/SoundContext.cpp b/src/crepe/SoundContext.cpp index b57e51a..cfb7d82 100644 --- a/src/crepe/SoundContext.cpp +++ b/src/crepe/SoundContext.cpp @@ -1,20 +1,20 @@ #include "util/log.h" -#include "SoundSystem.h" +#include "SoundContext.h" using namespace crepe; -SoundSystem & SoundSystem::get_instance() { - static SoundSystem instance; +SoundContext & SoundContext::get_instance() { + static SoundContext instance; return instance; } -SoundSystem::SoundSystem() { +SoundContext::SoundContext() { dbg_trace(); engine.init(); } -SoundSystem::~SoundSystem() { +SoundContext::~SoundContext() { dbg_trace(); engine.deinit(); } diff --git a/src/crepe/SoundContext.h b/src/crepe/SoundContext.h index 34dd6c5..d361d83 100644 --- a/src/crepe/SoundContext.h +++ b/src/crepe/SoundContext.h @@ -6,17 +6,17 @@ namespace crepe { -class SoundSystem { +class SoundContext { private: - SoundSystem(); - virtual ~SoundSystem(); + SoundContext(); + virtual ~SoundContext(); // singleton - static SoundSystem & get_instance(); - SoundSystem(const SoundSystem &) = delete; - SoundSystem(SoundSystem &&) = delete; - SoundSystem &operator=(const SoundSystem &) = delete; - SoundSystem &operator=(SoundSystem &&) = delete; + static SoundContext & get_instance(); + SoundContext(const SoundContext &) = delete; + SoundContext(SoundContext &&) = delete; + SoundContext &operator=(const SoundContext &) = delete; + SoundContext &operator=(SoundContext &&) = delete; private: SoLoud::Soloud engine; -- cgit v1.2.3