aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-01-14 18:33:30 +0000
committerTorbjörn Andersson2004-01-14 18:33:30 +0000
commit4980331ecf1f78124af8e1f09e174c0f25fea778 (patch)
tree80effe64d8579c67a2825efdc400fe1ddc570e7d
parent6ca6f13c6d3d9b8ecdd3c92c6c24ad6dee9d14f4 (diff)
downloadscummvm-rg350-4980331ecf1f78124af8e1f09e174c0f25fea778.tar.gz
scummvm-rg350-4980331ecf1f78124af8e1f09e174c0f25fea778.tar.bz2
scummvm-rg350-4980331ecf1f78124af8e1f09e174c0f25fea778.zip
I accidentally introduced a bug when I changed the fading that would cause
fading-up music to distort and eventually deteriorate into white noise. This was because I allowed _fade to be set on channels that weren't playing and because I only checked _fade for equality when deciding when to stop the fading. It should work much better now, I think. svn-id: r12392
-rw-r--r--sword2/driver/d_sound.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 2a2a442896..2f4253b85b 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -131,17 +131,21 @@ int32 Sound::_musicVolTable[17] = {
};
void MusicHandle::fadeDown(void) {
- if (_fading < 0)
- _fading = -_fading;
- else if (_fading == 0)
- _fading = FADE_SAMPLES;
+ if (_streaming) {
+ if (_fading < 0)
+ _fading = -_fading;
+ else if (_fading == 0)
+ _fading = FADE_SAMPLES;
+ }
}
void MusicHandle::fadeUp(void) {
- if (_fading > 0)
- _fading = -_fading;
- else if (_fading == 0)
- _fading = -1;
+ if (_streaming) {
+ if (_fading > 0)
+ _fading = -_fading;
+ else if (_fading == 0)
+ _fading = -1;
+ }
}
int32 MusicHandle::play(const char *filename, uint32 musicId, bool looping) {
@@ -223,7 +227,7 @@ int MusicHandle::readBuffer(int16 *buffer, const int numSamples) {
} else if (_fading < 0) {
_fading--;
out = -(out * _fading) / FADE_SAMPLES;
- if (_fading == -FADE_SAMPLES)
+ if (_fading <= -FADE_SAMPLES)
_fading = 0;
}
}
@@ -353,10 +357,8 @@ void Sound::restoreMusicState(void) {
// Fade out any music that happens to be playing
- for (int i = 0; i < MAXMUS; i++) {
- if (_music[i]._streaming)
- _music[i].fadeDown();
- }
+ for (int i = 0; i < MAXMUS; i++)
+ _music[i].fadeDown();
if (!_music[2]._streaming)
return;