aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/gamemodule.cpp2
-rw-r--r--engines/neverhood/sound.cpp46
-rw-r--r--engines/neverhood/sound.h4
3 files changed, 44 insertions, 8 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 70450e2918..96e8cc13a6 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -411,6 +411,8 @@ void GameModule::checkRequests() {
}
if (_restoreGameRequested) {
_restoreGameRequested = false;
+ _vm->_audioResourceMan->stopAllSounds();
+ _vm->_soundMan->stopAllSounds();
delete _childObject;
delete _prevChildObject;
_childObject = NULL;
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index c84b751e44..46ec8007b0 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -254,10 +254,26 @@ SoundMan::SoundMan(NeverhoodEngine *vm)
}
SoundMan::~SoundMan() {
- for (uint i = 0; i < _soundItems.size(); ++i)
- delete _soundItems[i];
- for (uint i = 0; i < _musicItems.size(); ++i)
- delete _musicItems[i];
+ stopAllSounds();
+}
+
+void SoundMan::stopAllSounds() {
+ for (uint i = 0; i < _soundItems.size(); ++i) {
+ if (_soundItems[i]) {
+ _soundItems[i]->stopSound();
+ delete _soundItems[i];
+ _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;
}
void SoundMan::addMusic(uint32 groupNameHash, uint32 musicFileHash) {
@@ -708,11 +724,25 @@ AudioResourceMan::AudioResourceMan(NeverhoodEngine *vm)
: _vm(vm) {
}
+void AudioResourceMan::stopAllSounds() {
+ for (uint i = 0; i < _soundItems.size(); ++i) {
+ if (_soundItems[i]) {
+ _soundItems[i]->stopSound();
+ delete _soundItems[i];
+ _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() {
- for (uint i = 0; i < _soundItems.size(); ++i)
- delete _soundItems[i];
- for (uint i = 0; i < _musicItems.size(); ++i)
- delete _musicItems[i];
+ stopAllSounds();
}
int16 AudioResourceMan::addSound(uint32 fileHash) {
diff --git a/engines/neverhood/sound.h b/engines/neverhood/sound.h
index d3318998db..aa5da284ea 100644
--- a/engines/neverhood/sound.h
+++ b/engines/neverhood/sound.h
@@ -129,6 +129,8 @@ public:
SoundMan(NeverhoodEngine *vm);
~SoundMan();
+ void stopAllSounds();
+
// Music
void addMusic(uint32 groupNameHash, uint32 musicFileHash);
void deleteMusic(uint32 musicFileHash);
@@ -262,6 +264,8 @@ public:
AudioResourceMan(NeverhoodEngine *vm);
~AudioResourceMan();
+ void stopAllSounds();
+
int16 addSound(uint32 fileHash);
void removeSound(int16 soundIndex);