diff options
author | Max Horn | 2008-01-06 00:09:05 +0000 |
---|---|---|
committer | Max Horn | 2008-01-06 00:09:05 +0000 |
commit | 1194495ad39ec8640f76c000825981952c44e6a8 (patch) | |
tree | d93e5fe95d8e05d3d5f241db9798453c99836f22 | |
parent | e52591ac0ef9f7611f3ce9c2b8b3e975fb3a4d3e (diff) | |
download | scummvm-rg350-1194495ad39ec8640f76c000825981952c44e6a8.tar.gz scummvm-rg350-1194495ad39ec8640f76c000825981952c44e6a8.tar.bz2 scummvm-rg350-1194495ad39ec8640f76c000825981952c44e6a8.zip |
cleanup
svn-id: r30284
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_script.cpp | 17 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_track.cpp | 12 |
3 files changed, 17 insertions, 20 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 0e1752007b..93e7e831ed 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -219,8 +219,8 @@ void IMuseDigital::callback() { Track *track = _track[l]; if (track->used) { // Remove tracks if necessary - if (track->toBeRemoved) { - flushTrack(track); + if (!_mixer->isSoundHandleActive(track->mixChanHandle)) { + memset(track, 0, sizeof(Track)); continue; } @@ -260,7 +260,7 @@ void IMuseDigital::callback() { if (track->curRegion == -1) { switchToNextRegion(track); - if (track->toBeRemoved) + if (track->toBeRemoved || !track->used) continue; } @@ -328,7 +328,7 @@ void IMuseDigital::callback() { if (_sound->isEndOfRegion(track->soundDesc, track->curRegion)) { switchToNextRegion(track); - if (track->toBeRemoved) + if (track->toBeRemoved || !track->used) break; } feedSize -= curFeedSize; diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 4a31d07c51..6473bbfc55 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -164,6 +164,8 @@ 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) { _mixer->stopHandle(track->mixChanHandle); } else if (track->stream) { @@ -181,12 +183,7 @@ void IMuseDigital::flushTrack(Track *track) { if (!_mixer->isSoundHandleActive(track->mixChanHandle)) { memset(track, 0, sizeof(Track)); - } - - // Set toBeRemoved to true, even if we just stopped the sound completly - // (and thus set "used" to false); - track->toBeRemoved = true; } void IMuseDigital::flushTracks() { @@ -194,8 +191,8 @@ 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) { - flushTrack(track); + if (track->used && track->toBeRemoved && !_mixer->isSoundHandleActive(track->mixChanHandle)) { + memset(track, 0, sizeof(Track)); } } } @@ -251,7 +248,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width Common::StackLock lock(_mutex, "IMuseDigital::getLipSync()"); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { _sound->getSyncSizeAndPtrById(track->soundDesc, syncId, sync_size, &sync_ptr); if ((sync_size != 0) && (sync_ptr != NULL)) { sync_size /= 4; @@ -279,7 +276,7 @@ int32 IMuseDigital::getPosInMs(int soundId) { Common::StackLock lock(_mutex, "IMuseDigital::getPosInMs()"); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->feedSize / 200); return pos; } @@ -310,7 +307,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 && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { flushTrack(); } } diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 3da2a5b56c..b2037d83fc 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -167,7 +167,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 && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->soundPriority = priority; } } @@ -179,7 +179,7 @@ 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 && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->vol = volume * 1000; } } @@ -190,7 +190,7 @@ void IMuseDigital::setHookId(int soundId, int hookId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->curHookId = hookId; } } @@ -230,7 +230,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 && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->pan = pan; } } @@ -246,7 +246,7 @@ 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 && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->volGroupId = volGroupId; } } @@ -258,7 +258,7 @@ void IMuseDigital::setFade(int soundId, int destVolume, int delay60HzTicks) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if (track->used && !track->toBeRemoved && (track->soundId == soundId)) { track->volFadeDelay = delay60HzTicks; track->volFadeDest = destVolume * 1000; track->volFadeStep = (track->volFadeDest - track->vol) * 60 * (1000 / _callbackFps) / (1000 * delay60HzTicks); |