aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorMax Horn2007-03-20 19:37:31 +0000
committerMax Horn2007-03-20 19:37:31 +0000
commit3d52e20b9b0519a2d9cbe3673ae6a16417a9598a (patch)
treea56f9fe9ff80565545f91a725cf64689be4240c5 /engines/scumm
parentd0c30bfd9ab8a9411d3c86ee0a3fce0714f6c993 (diff)
downloadscummvm-rg350-3d52e20b9b0519a2d9cbe3673ae6a16417a9598a.tar.gz
scummvm-rg350-3d52e20b9b0519a2d9cbe3673ae6a16417a9598a.tar.bz2
scummvm-rg350-3d52e20b9b0519a2d9cbe3673ae6a16417a9598a.zip
Change IMuseDigital::stopAllSounds to simply do what it names suggest, i.e. stop all sounds immediately (instead of waiting for the imuse timer to do the required work). Not heavily tested, as I don't know of specific spots in Dig/FT/CoMI which make use of this
svn-id: r26258
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp2
-rw-r--r--engines/scumm/imuse_digi/dimuse_script.cpp46
2 files changed, 28 insertions, 20 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index e844363043..cf4c0ca86e 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -67,8 +67,8 @@ IMuseDigital::IMuseDigital(ScummEngine_v7 *scumm, Audio::Mixer *mixer, int fps)
}
IMuseDigital::~IMuseDigital() {
- stopAllSounds();
_vm->_timer->removeTimerProc(timer_handler);
+ stopAllSounds();
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
delete _track[l];
}
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp
index 1a257c905f..1ee71b51da 100644
--- a/engines/scumm/imuse_digi/dimuse_script.cpp
+++ b/engines/scumm/imuse_digi/dimuse_script.cpp
@@ -165,11 +165,13 @@ void IMuseDigital::flushTracks() {
debug(5, "flushTracks()");
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->readyToRemove)) {
+ if (track->used && track->readyToRemove) {
if (track->stream) {
- if (!track->stream->endOfStream()) {
- track->stream->finish();
- }
+ // Finalize the appendable stream
+ track->stream->finish();
+ // 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->handle);
delete track->stream;
@@ -378,24 +380,30 @@ int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) {
}
void IMuseDigital::stopAllSounds() {
- debug(5, "IMuseDigital::stopAllSounds");
+ Common::StackLock lock(_mutex, "IMuseDigital::stopAllSounds()");
+ debug(0, "IMuseDigital::stopAllSounds");
- for (;;) {
- bool foundNotRemoved = false;
- for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
- Track *track = _track[l];
- if (track->used) {
- track->toBeRemoved = true;
- foundNotRemoved = true;
+ for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
+ Track *track = _track[l];
+ if (track->used) {
+ // Stop the sound output, *now*. No need to use toBeRemoved etc.
+ // as we are protected by a mutex, and this method is never called
+ // from IMuseDigital::callback either.
+ if (track->stream) {
+ _mixer->stopHandle(track->handle);
+ delete track->stream;
+ track->stream = NULL;
+ _sound->closeSound(track->soundHandle);
+ track->soundHandle = NULL;
+ } else if (track->stream2) {
+ _mixer->stopHandle(track->handle);
+ delete track->stream2;
+ track->stream2 = NULL;
}
+
+ // Mark the track as unused
+ track->used = false;
}
- if (!foundNotRemoved)
- break;
- flushTracks();
- _vm->_system->delayMillis(50);
-#if defined(_WIN32_WCE) || defined (PALMOS_MODE) || defined(__SYMBIAN32__)
- _vm->parseEvents(); // timers are events, we need to consume them
-#endif
}
}