aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/neverhood/sound.cpp')
-rw-r--r--engines/neverhood/sound.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index c3bc3501b5..1fd09674a2 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -254,9 +254,20 @@ SoundMan::SoundMan(NeverhoodEngine *vm)
}
SoundMan::~SoundMan() {
+ stopAllMusic();
stopAllSounds();
}
+void SoundMan::stopAllMusic() {
+ for (uint i = 0; i < _musicItems.size(); ++i) {
+ if (_musicItems[i]) {
+ _musicItems[i]->stopMusic(0, 0);
+ delete _musicItems[i];
+ _musicItems[i] = NULL;
+ }
+ }
+}
+
void SoundMan::stopAllSounds() {
for (uint i = 0; i < _soundItems.size(); ++i) {
if (_soundItems[i]) {
@@ -265,13 +276,6 @@ void SoundMan::stopAllSounds() {
_soundItems[i] = NULL;
}
}
- for (uint i = 0; i < _musicItems.size(); ++i) {
- if (_musicItems[i]) {
- _musicItems[i]->stopMusic(0, 0);
- delete _musicItems[i];
- _musicItems[i] = NULL;
- }
- }
_soundIndex1 = _soundIndex2 = _soundIndex3 = -1;
}
@@ -724,6 +728,16 @@ AudioResourceMan::AudioResourceMan(NeverhoodEngine *vm)
: _vm(vm) {
}
+void AudioResourceMan::stopAllMusic() {
+ for (uint i = 0; i < _musicItems.size(); ++i) {
+ if (_musicItems[i]) {
+ _musicItems[i]->stopMusic(0);
+ delete _musicItems[i];
+ _musicItems[i] = NULL;
+ }
+ }
+}
+
void AudioResourceMan::stopAllSounds() {
for (uint i = 0; i < _soundItems.size(); ++i) {
if (_soundItems[i]) {
@@ -732,16 +746,10 @@ void AudioResourceMan::stopAllSounds() {
_soundItems[i] = NULL;
}
}
- for (uint i = 0; i < _musicItems.size(); ++i) {
- if (_musicItems[i]) {
- _musicItems[i]->stopMusic(0);
- delete _musicItems[i];
- _musicItems[i] = NULL;
- }
- }
}
AudioResourceMan::~AudioResourceMan() {
+ stopAllMusic();
stopAllSounds();
}