aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sword2/driver/d_sound.cpp17
-rw-r--r--sword2/sound.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 66baf797d5..1b6177807d 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -487,6 +487,21 @@ void Sound::stopMusic() {
int32 Sound::streamCompMusic(uint32 musicId, bool loop) {
Common::StackLock lock(_mutex);
+ int cd = _vm->_resman->whichCd();
+
+ // HACK: We only have one music file handle, so if any music from the
+ // "wrong" CD is playing, kill it immediately.
+
+ for (int i = 0; i < MAXMUS; i++) {
+ if (_music[i] && _music[i]->whichCd() != cd) {
+ delete _music[i];
+ _music[i] = NULL;
+
+ if (fpMus.isOpen())
+ fpMus.close();
+ }
+ }
+
if (loop)
_loopingMusicId = musicId;
else
@@ -545,7 +560,7 @@ int32 Sound::streamCompMusic(uint32 musicId, bool loop) {
if (secondary != -1)
_music[secondary]->fadeDown();
- _music[primary] = new MusicInputStream(_vm->_resman->whichCd(), musicId, loop);
+ _music[primary] = new MusicInputStream(cd, musicId, loop);
if (!_music[primary]->isReady()) {
delete _music[primary];
diff --git a/sword2/sound.h b/sword2/sound.h
index 9eeda246b5..f38c106d8d 100644
--- a/sword2/sound.h
+++ b/sword2/sound.h
@@ -126,6 +126,8 @@ public:
bool isStereo() const { return _decoder->isStereo(); }
int getRate() const { return _decoder->getRate(); }
+ int whichCd() { return _cd; }
+
void fadeUp();
void fadeDown();