[Scummvm-cvs-logs] SF.net SVN: scummvm: [26258] scummvm/trunk/engines/scumm/imuse_digi
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Mar 20 20:37:32 CET 2007
Revision: 26258
http://scummvm.svn.sourceforge.net/scummvm/?rev=26258&view=rev
Author: fingolfin
Date: 2007-03-20 12:37:31 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp 2007-03-20 19:06:37 UTC (rev 26257)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse.cpp 2007-03-20 19:37:31 UTC (rev 26258)
@@ -67,8 +67,8 @@
}
IMuseDigital::~IMuseDigital() {
+ _vm->_timer->removeTimerProc(timer_handler);
stopAllSounds();
- _vm->_timer->removeTimerProc(timer_handler);
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
delete _track[l];
}
Modified: scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp 2007-03-20 19:06:37 UTC (rev 26257)
+++ scummvm/trunk/engines/scumm/imuse_digi/dimuse_script.cpp 2007-03-20 19:37:31 UTC (rev 26258)
@@ -165,11 +165,13 @@
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 @@
}
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
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list