aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorPaweł Kołodziejski2006-02-05 13:48:27 +0000
committerPaweł Kołodziejski2006-02-05 13:48:27 +0000
commit9555cd4df46d81a8f6fdcaea3eece76037ab8ca4 (patch)
treec7b58f7a54fd89ea237fb46597ba4d69291acff1 /scumm
parentfefb38d17a91080b6815ac85776b374ff05f4367 (diff)
downloadscummvm-rg350-9555cd4df46d81a8f6fdcaea3eece76037ab8ca4.tar.gz
scummvm-rg350-9555cd4df46d81a8f6fdcaea3eece76037ab8ca4.tar.bz2
scummvm-rg350-9555cd4df46d81a8f6fdcaea3eece76037ab8ca4.zip
revert experimental imuse changes
svn-id: r20394
Diffstat (limited to 'scumm')
-rw-r--r--scumm/imuse_digi/dimuse.cpp250
-rw-r--r--scumm/imuse_digi/dimuse.h11
-rw-r--r--scumm/imuse_digi/dimuse_script.cpp25
-rw-r--r--scumm/imuse_digi/dimuse_track.cpp91
-rw-r--r--scumm/script.cpp6
-rw-r--r--scumm/scumm.cpp5
-rw-r--r--scumm/smush/smush_player.cpp1
7 files changed, 192 insertions, 197 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp
index 48f88d2b21..6633ef5182 100644
--- a/scumm/imuse_digi/dimuse.cpp
+++ b/scumm/imuse_digi/dimuse.cpp
@@ -38,20 +38,23 @@ IMuseDigital::Track::Track()
: soundId(-1), used(false), stream(NULL), stream2(NULL) {
}
+void IMuseDigital::timer_handler(void *refCon) {
+ IMuseDigital *imuseDigital = (IMuseDigital *)refCon;
+ imuseDigital->callback();
+}
+
IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps)
: _vm(scumm) {
_pause = false;
_sound = new ImuseDigiSndMgr(_vm);
_callbackFps = fps;
- _interval = 1000000 / fps;
- _counter = _interval;
- _firstCall = true;
resetState();
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
_track[l] = new Track;
_track[l]->trackId = l;
_track[l]->used = false;
}
+ _vm->_timer->installTimerProc(timer_handler, 1000000 / _callbackFps, this);
_audioNames = NULL;
_numAudioNames = 0;
@@ -59,6 +62,7 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps)
IMuseDigital::~IMuseDigital() {
stopAllSounds();
+ _vm->_timer->removeTimerProc(timer_handler);
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
delete _track[l];
}
@@ -75,6 +79,8 @@ void IMuseDigital::resetState() {
}
void IMuseDigital::saveOrLoad(Serializer *ser) {
+ Common::StackLock lock(_mutex, "IMuseDigital::saveOrLoad()");
+
const SaveLoadEntry mainEntries[] = {
MK_OBSOLETE(IMuseDigital, _volVoice, sleInt32, VER(31), VER(42)),
MK_OBSOLETE(IMuseDigital, _volSfx, sleInt32, VER(31), VER(42)),
@@ -197,154 +203,142 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
}
void IMuseDigital::callback() {
- if (_firstCall) {
- _thisTime = _vm->_system->getMillis();
- _firstCall = false;
- }
-
- _lastTime = _thisTime;
- _thisTime = _vm->_system->getMillis();
- int32 interval = 1000 * (_thisTime - _lastTime);
- if (interval > 100000) {
- warning("IMuseDigital::callback: long interval: %d", interval);
- interval = _interval;
- }
-
- _counter -= interval;
+ Common::StackLock lock(_mutex, "IMuseDigital::callback()");
- while (_counter <= 0) {
- _counter += _interval;
+ for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
+ Track *track = _track[l];
+ if (track->used && !track->readyToRemove) {
+ if (track->toBeRemoved) {
+ track->readyToRemove = true;
+ continue;
+ }
- if (_vm->_quit)
- return;
+ if (_pause || !_vm)
+ return;
- for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
- Track *track = _track[l];
- if (track->used && !track->toBeRemoved) {
- if (track->volFadeUsed) {
- if (track->volFadeStep < 0) {
- if (track->vol > track->volFadeDest) {
- track->vol += track->volFadeStep;
- if (track->vol < track->volFadeDest) {
- track->vol = track->volFadeDest;
- track->volFadeUsed = false;
- }
- if (track->vol == 0) {
- track->toBeRemoved = true;
- }
- }
- } else if (track->volFadeStep > 0) {
+ if (track->volFadeUsed) {
+ if (track->volFadeStep < 0) {
+ if (track->vol > track->volFadeDest) {
+ track->vol += track->volFadeStep;
if (track->vol < track->volFadeDest) {
- track->vol += track->volFadeStep;
+ track->vol = track->volFadeDest;
+ track->volFadeUsed = false;
+ }
+ if (track->vol == 0) {
+ track->toBeRemoved = true;
+ }
+ }
+ } else if (track->volFadeStep > 0) {
+ if (track->vol < track->volFadeDest) {
+ track->vol += track->volFadeStep;
if (track->vol > track->volFadeDest) {
- track->vol = track->volFadeDest;
- track->volFadeUsed = false;
- }
+ track->vol = track->volFadeDest;
+ track->volFadeUsed = false;
}
}
- debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000);
}
+ debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000);
+ }
+
+ const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
+ const int vol = track->vol / 1000;
+ Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
+
+ if (track->volGroupId == 1)
+ type = Audio::Mixer::kSpeechSoundType;
+ if (track->volGroupId == 2)
+ type = Audio::Mixer::kSFXSoundType;
+ if (track->volGroupId == 3)
+ type = Audio::Mixer::kMusicSoundType;
- const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- const int vol = track->vol / 1000;
- Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
+ if (track->stream) {
+ byte *data = NULL;
+ int32 result = 0;
- if (track->volGroupId == 1)
- type = Audio::Mixer::kSpeechSoundType;
- if (track->volGroupId == 2)
- type = Audio::Mixer::kSFXSoundType;
- if (track->volGroupId == 3)
- type = Audio::Mixer::kMusicSoundType;
+ if (track->curRegion == -1) {
+ switchToNextRegion(track);
+ if (track->toBeRemoved)
+ continue;
+ }
- if (track->stream) {
- byte *data = NULL;
- int32 result = 0;
+ int bits = _sound->getBits(track->soundHandle);
+ int channels = _sound->getChannels(track->soundHandle);
- if (track->curRegion == -1) {
- switchToNextRegion(track);
- if (track->toBeRemoved)
- continue;
- }
+ int32 mixer_size = track->iteration / _callbackFps;
- int bits = _sound->getBits(track->soundHandle);
- int channels = _sound->getChannels(track->soundHandle);
+ if (track->stream->endOfData()) {
+ mixer_size *= 2;
+ }
- int32 mixer_size = track->iteration / _callbackFps;
+ if ((bits == 12) || (bits == 16)) {
+ if (channels == 1)
+ mixer_size &= ~1;
+ if (channels == 2)
+ mixer_size &= ~3;
+ } else {
+ if (channels == 2)
+ mixer_size &= ~1;
+ }
- if (track->stream->endOfData()) {
- mixer_size *= 2;
- }
+ if (mixer_size == 0)
+ continue;
- if ((bits == 12) || (bits == 16)) {
- if (channels == 1)
- mixer_size &= ~1;
- if (channels == 2)
- mixer_size &= ~3;
- } else {
- if (channels == 2)
- mixer_size &= ~1;
- }
+ do {
+ if (bits == 12) {
+ byte *ptr = NULL;
- if (mixer_size == 0)
- continue;
+ mixer_size += track->mod;
+ int mixer_size_12 = (mixer_size * 3) / 4;
+ int length = (mixer_size_12 / 3) * 4;
+ track->mod = mixer_size - length;
- do {
- if (bits == 12) {
- byte *ptr = NULL;
-
- mixer_size += track->mod;
- int mixer_size_12 = (mixer_size * 3) / 4;
- int length = (mixer_size_12 / 3) * 4;
- track->mod = mixer_size - length;
-
- int32 offset = (track->regionOffset * 3) / 4;
- int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12);
- result = BundleCodecs::decode12BitsSample(ptr, &data, result2);
-
- free(ptr);
- } else if (bits == 16) {
- result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
- if (channels == 1) {
- result &= ~1;
- }
- if (channels == 2) {
- result &= ~3;
- }
- } else if (bits == 8) {
- result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
- if (channels == 2) {
- result &= ~1;
+ int32 offset = (track->regionOffset * 3) / 4;
+ int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12);
+ result = BundleCodecs::decode12BitsSample(ptr, &data, result2);
+
+ free(ptr);
+ } else if (bits == 16) {
+ result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
+ if (channels == 1) {
+ result &= ~1;
}
+ if (channels == 2) {
+ result &= ~3;
}
-
- if (result > mixer_size)
- result = mixer_size;
-
- if (_vm->_mixer->isReady()) {
- _vm->_mixer->setChannelVolume(track->handle, vol);
- _vm->_mixer->setChannelBalance(track->handle, pan);
- track->stream->append(data, result);
- track->regionOffset += result;
+ } else if (bits == 8) {
+ result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
+ if (channels == 2) {
+ result &= ~1;
}
- free(data);
+ }
+
+ if (result > mixer_size)
+ result = mixer_size;
- if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) {
- switchToNextRegion(track);
- if (track->toBeRemoved)
- break;
- }
- mixer_size -= result;
- assert(mixer_size >= 0);
- } while (mixer_size != 0);
- } else if (track->stream2) {
if (_vm->_mixer->isReady()) {
- if (!track->started) {
- track->started = true;
- _vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false);
- } else {
- _vm->_mixer->setChannelVolume(track->handle, vol);
- _vm->_mixer->setChannelBalance(track->handle, pan);
- }
+ _vm->_mixer->setChannelVolume(track->handle, vol);
+ _vm->_mixer->setChannelBalance(track->handle, pan);
+ track->stream->append(data, result);
+ track->regionOffset += result;
+ }
+ free(data);
+
+ if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) {
+ switchToNextRegion(track);
+ if (track->toBeRemoved)
+ break;
+ }
+ mixer_size -= result;
+ assert(mixer_size >= 0);
+ } while (mixer_size != 0);
+ } else if (track->stream2) {
+ if (_vm->_mixer->isReady()) {
+ if (!track->started) {
+ track->started = true;
+ _vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false);
+ } else {
+ _vm->_mixer->setChannelVolume(track->handle, vol);
+ _vm->_mixer->setChannelBalance(track->handle, pan);
}
}
}
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index f072b11b1a..34d9e91098 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -45,6 +45,8 @@ class Serializer;
class IMuseDigital : public MusicEngine {
private:
+ int _callbackFps;
+
struct Track {
int trackId;
@@ -84,6 +86,7 @@ private:
Track *_track[MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS];
+ Common::Mutex _mutex;
ScummEngine *_vm;
ImuseDigiSndMgr *_sound;
@@ -98,10 +101,8 @@ private:
int32 _curMusicSeq;
int32 _curMusicCue;
- int _callbackFps;
- int32 _lastTime, _thisTime, _interval, _counter;
- bool _firstCall;
-
+ static void timer_handler(void *refConf);
+ void callback();
void switchToNextRegion(Track *track);
int allocSlot(int priority);
void startSound(int soundId, const char *soundName, int soundType, int volGroupId, AudioStream *input, int hookId, int volume, int priority);
@@ -131,8 +132,6 @@ public:
IMuseDigital(ScummEngine *scumm, int fps);
virtual ~IMuseDigital();
- void callback();
-
void setAudioNames(int32 num, char *names);
void startVoice(int soundId, AudioStream *input);
diff --git a/scumm/imuse_digi/dimuse_script.cpp b/scumm/imuse_digi/dimuse_script.cpp
index f38462e4f8..7dc435017e 100644
--- a/scumm/imuse_digi/dimuse_script.cpp
+++ b/scumm/imuse_digi/dimuse_script.cpp
@@ -163,7 +163,7 @@ 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->toBeRemoved) {
+ if (track->used && track->readyToRemove) {
if (track->stream) {
if (!track->stream->endOfStream()) {
track->stream->finish();
@@ -192,7 +192,7 @@ void IMuseDigital::refreshScripts() {
bool found = false;
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
found = true;
}
}
@@ -236,7 +236,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width
if (msPos < 65536) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
_sound->getSyncSizeAndPtrById(track->soundHandle, syncId, sync_size, &sync_ptr);
if ((sync_size != 0) && (sync_ptr != NULL)) {
sync_size /= 4;
@@ -263,7 +263,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width
int32 IMuseDigital::getPosInMs(int soundId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200);
return pos;
}
@@ -278,7 +278,7 @@ int IMuseDigital::getSoundStatus(int sound) const {
Track *track = _track[l];
if (track->soundId == sound) {
if ((track->stream2 && _vm->_mixer->isSoundHandleActive(track->handle)) ||
- (track->stream && track->used)) {
+ (track->stream && track->used && !track->readyToRemove)) {
return 1;
}
}
@@ -291,7 +291,7 @@ void IMuseDigital::stopSound(int soundId) {
debug(5, "IMuseDigital::stopSound(%d)", soundId);
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->toBeRemoved = true;
}
}
@@ -302,7 +302,7 @@ int32 IMuseDigital::getCurMusicPosInMs() {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
soundId = track->soundId;
}
}
@@ -335,7 +335,7 @@ int32 IMuseDigital::getCurMusicLipSyncWidth(int syncId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
soundId = track->soundId;
}
}
@@ -353,7 +353,7 @@ int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
soundId = track->soundId;
}
}
@@ -381,13 +381,14 @@ void IMuseDigital::stopAllSounds() {
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
}
}
void IMuseDigital::pause(bool p) {
- if ((_pause) && (!p)) {
- _thisTime = _vm->_system->getMillis();
- }
_pause = p;
}
diff --git a/scumm/imuse_digi/dimuse_track.cpp b/scumm/imuse_digi/dimuse_track.cpp
index 7e8711f6c0..3723705c14 100644
--- a/scumm/imuse_digi/dimuse_track.cpp
+++ b/scumm/imuse_digi/dimuse_track.cpp
@@ -47,7 +47,8 @@ int IMuseDigital::allocSlot(int priority) {
debug(5, "IMuseDigital::startSound(): All slots are full");
for (l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (lowest_priority > track->priority) && !track->stream2) {
+ if (track->used && !track->toBeRemoved &&
+ (lowest_priority > track->priority) && !track->stream2) {
lowest_priority = track->priority;
trackId = l;
}
@@ -77,9 +78,15 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
Track *track = _track[l];
while (track->used) {
// The designated track is not yet available. So, we call flushTracks()
- // to get it processed (and thus made ready for us).
+ // to get it processed (and thus made ready for us). Since the actual
+ // processing is done by another thread, we also call parseEvents to
+ // give it some time (and to avoid busy waiting/looping).
flushTracks();
+#ifndef __PLAYSTATION2__
+ _vm->parseEvents();
+#endif
}
+
track->pan = 64;
track->vol = volume * 1000;
track->volFadeDest = 0;
@@ -184,7 +191,7 @@ void IMuseDigital::setPriority(int soundId, int priority) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->priority = priority;
}
}
@@ -195,16 +202,18 @@ void IMuseDigital::setVolume(int soundId, int volume) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->vol = volume * 1000;
}
}
}
void IMuseDigital::setHookId(int soundId, int hookId) {
+ Common::StackLock lock(_mutex, "IMuseDigital::setHookId()");
+
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->curHookId = hookId;
}
}
@@ -215,7 +224,7 @@ int IMuseDigital::getCurMusicSoundId() {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
soundId = track->soundId;
}
}
@@ -228,7 +237,7 @@ char *IMuseDigital::getCurMusicSoundName() {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
soundName = track->soundName;
}
}
@@ -241,7 +250,7 @@ void IMuseDigital::setPan(int soundId, int pan) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->pan = pan;
}
}
@@ -256,18 +265,19 @@ void IMuseDigital::selectVolumeGroup(int soundId, int volGroupId) {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->volGroupId = volGroupId;
}
}
}
void IMuseDigital::setFade(int soundId, int destVolume, int delay60HzTicks) {
+ Common::StackLock lock(_mutex, "IMuseDigital::setFade()");
debug(5, "IMuseDigital::setFade(%d, %d, %d)", soundId, destVolume, delay60HzTicks);
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if ((track->soundId == soundId) && track->used) {
+ if ((track->soundId == soundId) && track->used && !track->toBeRemoved) {
track->volFadeDelay = delay60HzTicks;
track->volFadeDest = destVolume * 1000;
track->volFadeStep = (track->volFadeDest - track->vol) * 60 * (1000 / _callbackFps) / (1000 * delay60HzTicks);
@@ -280,7 +290,7 @@ void IMuseDigital::fadeOutMusic(int fadeDelay) {
debug(5, "IMuseDigital::fadeOutMusic");
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
- if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
cloneToFadeOutTrack(track, fadeDelay);
track->toBeRemoved = true;
}
@@ -293,36 +303,39 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
debug(5, "IMuseDigital::cloneToFadeOutTrack(%d, %d)", track->trackId, fadeDelay);
- for (int l = MAX_DIGITAL_TRACKS; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
- if (!_track[l]->used) {
- fadeTrack = _track[l];
- break;
+ {
+ Common::StackLock lock(_mutex, "IMuseDigital::cloneToFadeOutTrack()");
+ for (int l = MAX_DIGITAL_TRACKS; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
+ if (!_track[l]->used) {
+ fadeTrack = _track[l];
+ break;
+ }
}
+ if (fadeTrack == 0)
+ error("IMuseDigital::cloneToFadeOutTrack() Can't find free fade track");
+
+ fadeTrack->pan = track->pan;
+ fadeTrack->vol = track->vol;
+ fadeTrack->volGroupId = track->volGroupId;
+ fadeTrack->priority = track->priority;
+ fadeTrack->soundId = track->soundId;
+ fadeTrack->dataOffset = track->dataOffset;
+ fadeTrack->regionOffset = track->regionOffset;
+ fadeTrack->curRegion = track->curRegion;
+ fadeTrack->curHookId = track->curHookId;
+ fadeTrack->iteration = track->iteration;
+ fadeTrack->mixerFlags = track->mixerFlags;
+ fadeTrack->mod = track->mod;
+ fadeTrack->toBeRemoved = track->toBeRemoved;
+ fadeTrack->readyToRemove = track->readyToRemove;
+ fadeTrack->souStream = track->souStream;
+ fadeTrack->started = track->started;
+ fadeTrack->stream2 = track->stream2;
+ strcpy(fadeTrack->soundName, track->soundName);
+ fadeTrack->soundType = track->soundType;
+ fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle);
+ assert(fadeTrack->soundHandle);
}
- if (fadeTrack == 0)
- error("IMuseDigital::cloneToFadeOutTrack() Can't find free fade track");
-
- fadeTrack->pan = track->pan;
- fadeTrack->vol = track->vol;
- fadeTrack->volGroupId = track->volGroupId;
- fadeTrack->priority = track->priority;
- fadeTrack->soundId = track->soundId;
- fadeTrack->dataOffset = track->dataOffset;
- fadeTrack->regionOffset = track->regionOffset;
- fadeTrack->curRegion = track->curRegion;
- fadeTrack->curHookId = track->curHookId;
- fadeTrack->iteration = track->iteration;
- fadeTrack->mixerFlags = track->mixerFlags;
- fadeTrack->mod = track->mod;
- fadeTrack->toBeRemoved = track->toBeRemoved;
- fadeTrack->readyToRemove = track->readyToRemove;
- fadeTrack->souStream = track->souStream;
- fadeTrack->started = track->started;
- fadeTrack->stream2 = track->stream2;
- strcpy(fadeTrack->soundName, track->soundName);
- fadeTrack->soundType = track->soundType;
- fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle);
- assert(fadeTrack->soundHandle);
fadeTrack->volFadeDelay = fadeDelay;
fadeTrack->volFadeDest = 0;
diff --git a/scumm/script.cpp b/scumm/script.cpp
index fd170e02b7..679503163d 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -465,12 +465,6 @@ void ScummEngine::executeScript() {
printf("\n");
}
-#ifndef DISABLE_SCUMM_7_8
- if (_imuseDigital) {
- _imuseDigital->callback();
- }
-#endif
-
executeOpcode(_opcode);
}
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index d82f66d56d..8b98fe882d 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -2339,11 +2339,6 @@ void ScummEngine::waitForTimer(int msec_delay) {
start_time = _system->getMillis();
while (!_quit) {
-#ifndef DISABLE_SCUMM_7_8
- if (_imuseDigital) {
- _imuseDigital->callback();
- }
-#endif
_sound->updateCD(); // Loop CD Audio if needed
parseEvents();
if (_system->getMillis() >= start_time + msec_delay)
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index 002910f41b..7d2a0b063e 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -1268,7 +1268,6 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) {
if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag)
break;
- _vm->_imuseDigital->callback();
_vm->_imuseDigital->flushTracks();
lastTime = thisTime;