diff options
author | Filippos Karapetis | 2013-06-12 11:17:41 +0300 |
---|---|---|
committer | Filippos Karapetis | 2013-06-12 11:35:47 +0300 |
commit | 323fe8c45bc9e602c7d8a043210e67811bab9d38 (patch) | |
tree | cfa924e0a0173efbb490114421b463d4f27b083b /engines/neverhood/sound.cpp | |
parent | 9d489e82ce3925150485e5bf50653c81e553bbcb (diff) | |
download | scummvm-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
Diffstat (limited to 'engines/neverhood/sound.cpp')
-rw-r--r-- | engines/neverhood/sound.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
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) { |