aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge
diff options
context:
space:
mode:
authorSimei Yin2017-08-18 04:36:23 +0200
committerSimei Yin2017-08-18 05:17:03 +0200
commitcc84534871ef8d609ffd87a8b7ad1219f8ff5935 (patch)
treeea3c5b1ac310c79ac8e91b1d080503e541492c3c /engines/sludge
parent0993264ba30382c67d950c2f8be7d2fbff34c5ed (diff)
downloadscummvm-rg350-cc84534871ef8d609ffd87a8b7ad1219f8ff5935.tar.gz
scummvm-rg350-cc84534871ef8d609ffd87a8b7ad1219f8ff5935.tar.bz2
scummvm-rg350-cc84534871ef8d609ffd87a8b7ad1219f8ff5935.zip
SLUDGE: Fix load&save sound bug
Diffstat (limited to 'engines/sludge')
-rw-r--r--engines/sludge/sound.cpp58
1 files changed, 12 insertions, 46 deletions
diff --git a/engines/sludge/sound.cpp b/engines/sludge/sound.cpp
index 297d01306c..6820ae14be 100644
--- a/engines/sludge/sound.cpp
+++ b/engines/sludge/sound.cpp
@@ -93,40 +93,16 @@ void SoundManager::killSoundStuff() {
if (!_soundOK)
return;
- _silenceIKillYou = true;
- for (int i = 0; i < MAX_SAMPLES; i ++) {
- if (g_sludge->_mixer->isSoundHandleActive(_soundCache[i].handle)) {
- g_sludge->_mixer->stopHandle(_soundCache[i].handle);
- }
- }
-#if 0
- for (int i = 0; i < MAX_MODS; i ++) {
- if (_modCache[i].playing) {
-
- if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) {
- debugOut("Failed to stop source: %s\n",
- alureGetErrorString());
- }
-
- }
-
- if (_modCache[i].stream != NULL) {
-
- if (! alureDestroyStream(modCache[i].stream, 0, NULL)) {
- debugOut("Failed to destroy stream: %s\n",
- alureGetErrorString());
- }
+ for (int i = 0; i < MAX_SAMPLES; ++i)
+ freeSound(i);
- }
- }
-#endif
- _silenceIKillYou = false;
+ for (int i = 0; i < MAX_MODS; ++i)
+ stopMOD(i);
}
/*
* Some setters:
*/
-
void SoundManager::setMusicVolume(int a, int v) {
if (!_soundOK)
return;
@@ -186,15 +162,10 @@ void SoundManager::huntKillSound(int filenum) {
return;
int gotSlot = findInSoundCache(filenum);
- if (gotSlot == -1) return;
-
- _silenceIKillYou = true;
-
- if (g_sludge->_mixer->isSoundHandleActive(_soundCache[gotSlot].handle)) {
- g_sludge->_mixer->stopHandle(_soundCache[gotSlot].handle);
- }
+ if (gotSlot == -1)
+ return;
- _silenceIKillYou = false;
+ freeSound(gotSlot);
}
void SoundManager::freeSound(int a) {
@@ -209,6 +180,8 @@ void SoundManager::freeSound(int a) {
handleSoundLists();
}
+ _soundCache[a].inSoundList = false;
+ _soundCache[a].looping = false;
_soundCache[a].fileLoaded = -1;
_silenceIKillYou = false;
@@ -322,20 +295,12 @@ int SoundManager::makeSoundAudioStream(int f, Audio::AudioStream *&audiostream,
return -1;
int a = findInSoundCache(f);
- if (a != -1) { // if this sound has been loaded before
- // still playing
- if (g_sludge->_mixer->isSoundHandleActive(_soundCache[a].handle)) {
- g_sludge->_mixer->stopHandle(_soundCache[a].handle); // stop it
- if (_soundCache[a].inSoundList) {
- handleSoundLists();
- }
- }
- } else {
+ if (a == -1) {
if (f == -2)
return -1;
a = findEmptySoundSlot();
- freeSound(a);
}
+ freeSound(a);
setResourceForFatal(f);
uint32 length = g_sludge->_resMan->openFileFromNum(f);
@@ -357,6 +322,7 @@ int SoundManager::makeSoundAudioStream(int f, Audio::AudioStream *&audiostream,
if (stream) {
audiostream = Audio::makeLoopingAudioStream(stream, loopy ? 0 : 1);
_soundCache[a].fileLoaded = f;
+ _soundCache[a].looping = loopy;
setResourceForFatal(-1);
} else {
audiostream = nullptr;