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.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index c3bc3501b5..3ea45491a7 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -250,13 +250,26 @@ void SoundItem::update() {
// SoundMan
SoundMan::SoundMan(NeverhoodEngine *vm)
- : _vm(vm), _soundIndex1(-1), _soundIndex2(-1), _soundIndex3(-1) {
+ : _vm(vm), _soundIndex1(-1), _soundIndex2(-1), _soundIndex3(-1),
+ _initialCountdown(0), _playOnceAfterCountdown(false),
+ _initialCountdown3(0), _playOnceAfterCountdown3(false) {
}
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 +278,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;
}
@@ -573,7 +579,7 @@ AudioResourceManSoundItem::AudioResourceManSoundItem(NeverhoodEngine *vm, uint32
void AudioResourceManSoundItem::loadSound() {
if (!_data && _resourceHandle.isValid() &&
(_resourceHandle.type() == kResTypeSound || _resourceHandle.type() == kResTypeMusic)) {
- _vm->_res->loadResource(_resourceHandle);
+ _vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
_data = _resourceHandle.data();
}
}
@@ -623,7 +629,8 @@ bool AudioResourceManSoundItem::isPlaying() {
AudioResourceManMusicItem::AudioResourceManMusicItem(NeverhoodEngine *vm, uint32 fileHash)
: _vm(vm), _fileHash(fileHash), _terminate(false), _canRestart(false),
- _volume(100), _panning(50), _start(false), _isFadingIn(false), _isFadingOut(false), _isPlaying(false) {
+ _volume(100), _panning(50), _start(false), _isFadingIn(false), _isFadingOut(false), _isPlaying(false),
+ _fadeVolume(0), _fadeVolumeStep(0) {
}
@@ -724,6 +731,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 +749,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();
}