diff options
author | Max Horn | 2008-01-05 23:53:28 +0000 |
---|---|---|
committer | Max Horn | 2008-01-05 23:53:28 +0000 |
commit | 1d34ce3baa6e7c2a3b77308082057409994b5a50 (patch) | |
tree | e58bf3ec4ea8eab81ba2e7312c0e984fa462d585 /engines/scumm/imuse_digi/dimuse_script.cpp | |
parent | ef9dac103f5610dd89d01cf52342d1325481e8ff (diff) | |
download | scummvm-rg350-1d34ce3baa6e7c2a3b77308082057409994b5a50.tar.gz scummvm-rg350-1d34ce3baa6e7c2a3b77308082057409994b5a50.tar.bz2 scummvm-rg350-1d34ce3baa6e7c2a3b77308082057409994b5a50.zip |
Let the audio mixer take care of (i.e. dispose) the Track::stream object, too
svn-id: r30277
Diffstat (limited to 'engines/scumm/imuse_digi/dimuse_script.cpp')
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_script.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 9e3337076a..185ef80e02 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -165,22 +165,26 @@ void IMuseDigital::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, i void IMuseDigital::flushTrack(Track *track) { track->toBeRemoved = true; - if (!track->souStreamUsed) { - assert(track->stream); - // Finalize the appendable stream - track->stream->finish(); - // There might still be some data left in the buffers of the + + if (track->souStreamUsed) { + _mixer->stopHandle(track->mixChanHandle); + } else if (track->stream) { + // Finalize the appendable stream, then remove our reference to it. + // Note that there might still be some data left in the buffers of the // appendable stream. We play it nice and wait till all of it - // played. - if (track->stream->endOfStream()) { - _mixer->stopHandle(track->mixChanHandle); - delete track->stream; + // played. The audio mixer will take care of it afterwards (and dispose it). + track->stream->finish(); + track->stream = 0; + if (track->soundDesc) _sound->closeSound(track->soundDesc); - memset(track, 0, sizeof(Track)); - } - } else { - _mixer->stopHandle(track->mixChanHandle); + } + + if (!_mixer->isSoundHandleActive(track->mixChanHandle)) { memset(track, 0, sizeof(Track)); + + // Still set toBeRemoved to true in case we are running inside the callback() + // function + track->toBeRemoved = true; } } @@ -396,9 +400,7 @@ void IMuseDigital::stopAllSounds() { // as we are protected by a mutex, and this method is never called // from IMuseDigital::callback either. _mixer->stopHandle(track->mixChanHandle); - if (!track->souStreamUsed) { - assert(track->stream); - delete track->stream; + if (track->soundDesc) { _sound->closeSound(track->soundDesc); } |