diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-24 02:09:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-24 02:09:36 +0300 |
commit | 890349c3d1ad29ff668a3ef7fd7c535ed9a876ef (patch) | |
tree | 343a3e21c2ded430d912b9b124d6239933ff3d25 | |
parent | 39b61e709ca41804af30410f4a82a99f34900a29 (diff) | |
download | manaplus-890349c3d1ad29ff668a3ef7fd7c535ed9a876ef.tar.gz manaplus-890349c3d1ad29ff668a3ef7fd7c535ed9a876ef.tar.bz2 manaplus-890349c3d1ad29ff668a3ef7fd7c535ed9a876ef.tar.xz manaplus-890349c3d1ad29ff668a3ef7fd7c535ed9a876ef.zip |
improve soundmanager class.
-rw-r--r-- | src/resources/soundeffect.cpp | 3 | ||||
-rw-r--r-- | src/resources/soundeffect.h | 2 | ||||
-rw-r--r-- | src/soundmanager.cpp | 32 | ||||
-rw-r--r-- | src/soundmanager.h | 2 |
4 files changed, 25 insertions, 14 deletions
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index 48772291b..2da3319e8 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -49,7 +49,8 @@ Resource *SoundEffect::load(SDL_RWops *const rw) } } -bool SoundEffect::play(const int loops, const int volume, const int channel) +bool SoundEffect::play(const int loops, const int volume, + const int channel) const { Mix_VolumeChunk(mChunk, volume); diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 67c28591b..50ddd562d 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -63,7 +63,7 @@ class SoundEffect final : public Resource * <code>false</code> otherwise. */ virtual bool play(const int loops, const int volume, - const int channel = -1); + const int channel = -1) const; protected: /** diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index 62471f07d..6eca843cd 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -163,7 +163,6 @@ void SoundManager::init() void SoundManager::info() const { SDL_version compiledVersion; - const SDL_version *linkedVersion; char driver[40] = "Unknown"; const char *format = "Unknown"; int rate = 0; @@ -171,19 +170,30 @@ void SoundManager::info() const int channels = 0; MIX_VERSION(&compiledVersion); - linkedVersion = Mix_Linked_Version(); + const SDL_version *const linkedVersion = Mix_Linked_Version(); SDL_AudioDriverName(driver, 40); Mix_QuerySpec(&rate, &audioFormat, &channels); switch (audioFormat) { - case AUDIO_U8: format = "U8"; break; - case AUDIO_S8: format = "S8"; break; - case AUDIO_U16LSB: format = "U16LSB"; break; - case AUDIO_S16LSB: format = "S16LSB"; break; - case AUDIO_U16MSB: format = "U16MSB"; break; - case AUDIO_S16MSB: format = "S16MSB"; break; + case AUDIO_U8: + format = "U8"; + break; + case AUDIO_S8: + format = "S8"; break; + case AUDIO_U16LSB: + format = "U16LSB"; + break; + case AUDIO_S16LSB: + format = "S16LSB"; + break; + case AUDIO_U16MSB: + format = "U16MSB"; + break; + case AUDIO_S16MSB: + format = "S16MSB"; + break; default: break; } @@ -337,7 +347,7 @@ void SoundManager::playSfx(const std::string &path, else tmpPath = paths.getValue("sfx", "sfx/").append(path); ResourceManager *const resman = ResourceManager::getInstance(); - SoundEffect *const sample = resman->getSoundEffect(tmpPath); + const SoundEffect *const sample = resman->getSoundEffect(tmpPath); if (sample) { logger->log("SoundManager::playSfx() Playing: %s", path.c_str()); @@ -377,7 +387,7 @@ void SoundManager::playGuiSfx(const std::string &path) else tmpPath = paths.getValue("sfx", "sfx/").append(path); ResourceManager *const resman = ResourceManager::getInstance(); - SoundEffect *const sample = resman->getSoundEffect(tmpPath); + const SoundEffect *const sample = resman->getSoundEffect(tmpPath); if (sample) { logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str()); @@ -430,7 +440,7 @@ void SoundManager::volumeOff() const } } -void SoundManager::volumeRestore() +void SoundManager::volumeRestore() const { if (mInstalled) { diff --git a/src/soundmanager.h b/src/soundmanager.h index 710e357f1..32fe27fbc 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -133,7 +133,7 @@ class SoundManager final : public ConfigListener void volumeOff() const; - void volumeRestore(); + void volumeRestore() const; std::string getCurrentMusicFile() const A_WARN_UNUSED { return mCurrentMusicFile; } |