aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2013-06-12 11:17:41 +0300
committerFilippos Karapetis2013-06-12 11:35:47 +0300
commit323fe8c45bc9e602c7d8a043210e67811bab9d38 (patch)
treecfa924e0a0173efbb490114421b463d4f27b083b
parent9d489e82ce3925150485e5bf50653c81e553bbcb (diff)
downloadscummvm-rg350-323fe8c45bc9e602c7d8a043210e67811bab9d38.tar.gz
scummvm-rg350-323fe8c45bc9e602c7d8a043210e67811bab9d38.tar.bz2
scummvm-rg350-323fe8c45bc9e602c7d8a043210e67811bab9d38.zip
NEVERHOOD: Stop all sounds before restoring / restarting
This fixes the static heard when loading a saved game to a scene with music, when the current scene also has music
-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);