aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2008-01-05 23:53:28 +0000
committerMax Horn2008-01-05 23:53:28 +0000
commit1d34ce3baa6e7c2a3b77308082057409994b5a50 (patch)
treee58bf3ec4ea8eab81ba2e7312c0e984fa462d585 /engines
parentef9dac103f5610dd89d01cf52342d1325481e8ff (diff)
downloadscummvm-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')
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp2
-rw-r--r--engines/scumm/imuse_digi/dimuse_script.cpp34
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp8
3 files changed, 22 insertions, 22 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index c79cc833ee..0e1752007b 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -206,7 +206,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
- _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan(), false);
+ _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan());
_mixer->pauseHandle(track->mixChanHandle, true);
}
}
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);
}
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index bc71e71b10..3da2a5b56c 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -63,9 +63,7 @@ int IMuseDigital::allocSlot(int priority) {
// Stop the track immediately
_mixer->stopHandle(track->mixChanHandle);
- if (!track->souStreamUsed) {
- assert(track->stream);
- delete track->stream;
+ if (!track->soundDesc) {
_sound->closeSound(track->soundDesc);
}
@@ -156,7 +154,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
#endif
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
- _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan(), false);
+ _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan());
}
track->used = true;
@@ -317,7 +315,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
// Create an appendable output buffer
fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundDesc), makeMixerFlags(fadeTrack->mixerFlags));
- _mixer->playInputStream(track->getType(), &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->getVol(), fadeTrack->getPan(), false);
+ _mixer->playInputStream(track->getType(), &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->getVol(), fadeTrack->getPan());
fadeTrack->used = true;
return fadeTrack;