diff options
-rw-r--r-- | src/sound.cpp | 15 | ||||
-rw-r--r-- | src/sound.h | 14 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/sound.cpp b/src/sound.cpp index 98fef632..f76b6910 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -25,6 +25,18 @@ #include "log.h" #include "main.h" +Sound::Sound(): + installed(false), + items(-1) +{ +} + +Sound::~Sound() +{ + stopMusic(); + close(); +} + void Sound::init() { // Don't initialize sound engine twice @@ -52,7 +64,6 @@ void Sound::init() info(); music = NULL; - items = -1; installed = true; } @@ -219,7 +230,7 @@ void Sound::playSfx(const char *path) void Sound::clearCache() { - for (SOUND_ID i = 0; i == items; i++) { + for (SOUND_ID i = 0; i <= items; i++) { soundPool[i]->unload(); delete soundPool[i]; soundPool[i] = NULL; diff --git a/src/sound.h b/src/sound.h index c0f2f3ba..96cb8baf 100644 --- a/src/sound.h +++ b/src/sound.h @@ -40,6 +40,16 @@ typedef short SOUND_ID; class Sound { public: /** + * Constructor. + */ + Sound(); + + /** + * Destructor. + */ + ~Sound(); + + /** * Installs the sound engine. */ void init(); @@ -123,10 +133,6 @@ class Sound { */ void clearCache(); - Sound() { installed = false; } - - ~Sound() { stopMusic(); close(); } - private: bool installed; |