diff options
author | Torbjörn Andersson | 2004-03-13 12:04:18 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-03-13 12:04:18 +0000 |
commit | 1f5d4dcd233e15aa1cc15f533cc4d65342164e15 (patch) | |
tree | 0a4546f92ad159985314a5932bf8de26a4bd6a93 | |
parent | 7f7f647e3c51e1a7da83a074116127cc48308f25 (diff) | |
download | scummvm-rg350-1f5d4dcd233e15aa1cc15f533cc4d65342164e15.tar.gz scummvm-rg350-1f5d4dcd233e15aa1cc15f533cc4d65342164e15.tar.bz2 scummvm-rg350-1f5d4dcd233e15aa1cc15f533cc4d65342164e15.zip |
When both music channels are used, and a third piece of music starts,
silence the channel that appears to be closest to silence already. This is
the same method I used in BS2, and it might fix a glitch I heard at the
Club Alamut.
svn-id: r13234
-rw-r--r-- | sword1/music.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/sword1/music.cpp b/sword1/music.cpp index ae0a9c0794..586a93638e 100644 --- a/sword1/music.cpp +++ b/sword1/music.cpp @@ -154,12 +154,27 @@ void Music::startMusic(int32 tuneId, int32 loopFlag) { if (strlen(_tuneList[tuneId]) > 0) { int newStream = 0; if (_handles[0].streaming() && _handles[1].streaming()) { - // If both handles are playing, stop the one that's - // fading down. - if (_handles[0].fading() > 0) - _handles[0].stop(); - else - _handles[1].stop(); + int streamToStop; + // Both streams playing - one must be forced to stop. + if (!_handles[0].fading() && !_handles[1].fading()) { + // None of them are fading. Shouldn't happen, + // so it doesn't matter which one we pick. + streamToStop = 0; + } else if (_handles[0].fading() && !_handles[1].fading()) { + // Stream 0 is fading, so pick that one. + streamToStop = 0; + } else if (!_handles[0].fading() && _handles[1].fading()) { + // Stream 1 is fading, so pick that one. + streamToStop = 1; + } else { + // Both streams are fading. Pick the one that + // is closest to silent. + if (ABS(_handles[0].fading()) < ABS(_handles[1].fading())) + streamToStop = 0; + else + streamToStop = 1; + } + _handles[streamToStop].stop(); } if (_handles[0].streaming()) { _handles[0].fadeDown(); |