aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp14
-rw-r--r--engines/scumm/imuse_digi/dimuse_script.cpp6
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp18
3 files changed, 12 insertions, 26 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index ff5731f526..76233dce26 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -151,27 +151,26 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
Track *track = _track[l];
- if (!ser->isSaving()) {
- track->sndDataExtComp = false;
+ if (ser->isLoading()) {
+ memset(track, 0, sizeof(Track));
}
ser->saveLoadEntries(track, trackEntries);
- if (!ser->isSaving()) {
+ if (ser->isLoading()) {
if (!track->used)
continue;
if ((track->toBeRemoved) || (track->souStreamUsed) || (track->curRegion == -1)) {
- track->streamSou= NULL;
- track->stream = NULL;
track->used = false;
continue;
}
+
+ // TODO: The code below has a lot in common with that in IMuseDigital::startSound.
+ // Try to refactor them to reduce the code duplication.
track->soundDesc = _sound->openSound(track->soundId,
track->soundName, track->soundType,
track->volGroupId, -1);
if (!track->soundDesc) {
warning("IMuseDigital::saveOrLoad: Can't open sound so will not be resumed, propably on diffrent CD");
- track->streamSou = NULL;
- track->stream = NULL;
track->used = false;
continue;
}
@@ -205,7 +204,6 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
track->mixerFlags |= kFlagLittleEndian;
#endif
- track->streamSou = NULL;
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp
index 79972459da..0d3ee7440b 100644
--- a/engines/scumm/imuse_digi/dimuse_script.cpp
+++ b/engines/scumm/imuse_digi/dimuse_script.cpp
@@ -404,17 +404,17 @@ void IMuseDigital::stopAllSounds() {
assert(track->stream);
_mixer->stopHandle(track->mixChanHandle);
delete track->stream;
- track->stream = NULL;
_sound->closeSound(track->soundDesc);
- track->soundDesc = NULL;
} else if (track->streamSou) {
assert(track->streamSou);
_mixer->stopHandle(track->mixChanHandle);
delete track->streamSou;
- track->streamSou = NULL;
}
// Mark the track as unused
+ track->soundDesc = NULL;
+ track->streamSou = NULL;
+ track->stream = NULL;
track->used = false;
}
}
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index 0f1cd8ba8e..7dff90b65a 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -92,24 +92,17 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
}
Track *track = _track[l];
+
+ // Reset the track
+ memset(track, 0, sizeof(Track));
track->pan = 64;
track->vol = volume * 1000;
- track->volFadeDest = 0;
- track->volFadeStep = 0;
- track->volFadeDelay = 0;
- track->volFadeUsed = false;
track->soundId = soundId;
- track->mixerStreamRunning = false;
track->volGroupId = volGroupId;
track->curHookId = hookId;
track->soundPriority = priority;
track->curRegion = -1;
- track->dataOffset = 0;
- track->regionOffset = 0;
- track->dataMod12Bit = 0;
- track->mixerFlags = 0;
- track->toBeRemoved = false;
track->soundType = soundType;
int bits = 0, freq = 0, channels = 0;
@@ -117,11 +110,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
track->souStreamUsed = (input != 0);
if (track->souStreamUsed) {
- track->feedSize = 0;
- track->soundName[0] = 0;
- track->soundDesc = NULL;
track->streamSou = input;
- track->stream = NULL;
track->mixerStreamRunning = false;
} else {
strcpy(track->soundName, soundName);
@@ -177,7 +166,6 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
if (track->volGroupId == 3)
type = Audio::Mixer::kMusicSoundType;
- track->streamSou = NULL;
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
_mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false);
track->mixerStreamRunning = true;