aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/sfx/music.cpp1
-rw-r--r--engines/sci/sfx/soundcmd.cpp10
2 files changed, 6 insertions, 5 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index 3956b0faeb..5fdf45db69 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -446,6 +446,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) {
// Remove sound from playlist
for (i = 0; i < sz; i++) {
if (_playList[i] == pSnd) {
+ delete _playList[i]->soundRes;
_playList.remove_at(i);
break;
}
diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp
index ecade498c3..297e926f7e 100644
--- a/engines/sci/sfx/soundcmd.cpp
+++ b/engines/sci/sfx/soundcmd.cpp
@@ -276,6 +276,11 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
PUT_SEL32(_segMan, obj, handle, obj);
#ifndef USE_OLD_MUSIC_FUNCTIONS
+ // Check if a track with the same sound object is already playing
+ int prevTrack = _music->findListSlot(obj);
+ if (prevTrack > -1)
+ _music->soundKill(_music->_playList[prevTrack]);
+
MusicEntry *newSound = new MusicEntry();
newSound->soundRes = 0;
if (_resMan->testResource(ResourceId(kResourceTypeSound, number)))
@@ -284,9 +289,6 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
newSound->prio = GET_SEL32V(_segMan, obj, pri) & 0xFF;
newSound->pStreamAud = 0;
newSound->pMidiParser = 0;
-
- // TODO
- //_music->soundKill(newSound);
_music->_playList.push_back(newSound);
if (newSound->soundRes)
@@ -424,8 +426,6 @@ void SoundCommandParser::cmdDisposeHandle(reg_t obj, int16 value) {
if (!GET_SEL32(_segMan, obj, nodePtr).isNull()) {
_music->soundKill(_music->_playList[slot]);
- delete _music->_playList[slot]->soundRes;
- _music->_playList.remove_at(slot);
PUT_SEL32(_segMan, obj, nodePtr, NULL_REG);
}