diff options
author | Willem Jan Palenstijn | 2006-02-26 01:25:27 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2006-02-26 01:25:27 +0000 |
commit | 06e02f60102fd4e41a4e4ff713be25cb4fbc083c (patch) | |
tree | 20300ca35fae93f50594fdea96bb61c47b610013 | |
parent | 76962c3ce68dc04791cb85ef3c9544c95fd00fc6 (diff) | |
download | scummvm-rg350-06e02f60102fd4e41a4e4ff713be25cb4fbc083c.tar.gz scummvm-rg350-06e02f60102fd4e41a4e4ff713be25cb4fbc083c.tar.bz2 scummvm-rg350-06e02f60102fd4e41a4e4ff713be25cb4fbc083c.zip |
stop playing a sample before deleting the sample data
svn-id: r20902
-rw-r--r-- | engines/gob/game.cpp | 9 | ||||
-rw-r--r-- | engines/gob/goblin.cpp | 2 | ||||
-rw-r--r-- | engines/gob/sound.cpp | 6 | ||||
-rw-r--r-- | engines/gob/sound.h | 5 |
4 files changed, 15 insertions, 7 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 7d5f68ada3..d982c47074 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -413,13 +413,16 @@ void Game::freeSoundSlot(int16 slot) { if (_soundSamples[slot] == 0) return; + char* data = _soundSamples[slot]->data; + + _vm->_snd->freeSoundDesc(_soundSamples[slot], false); + _soundSamples[slot] = 0; + if (_soundFromExt[slot] == 1) { - delete[] (_soundSamples[slot]->data - 6); + delete[] (data - 6); _soundFromExt[slot] = 0; } - delete _soundSamples[slot]; - _soundSamples[slot] = 0; } int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY, int16 *pButtons, char handleMouse) { diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 5b0df56be3..629a31bd05 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -1825,7 +1825,7 @@ void Goblin::freeObjects(void) { if (_soundData[i] == 0) continue; - _vm->_snd->freeSoundData(_soundData[i]); + _vm->_snd->freeSoundDesc(_soundData[i]); _soundData[i] = 0; } diff --git a/engines/gob/sound.cpp b/engines/gob/sound.cpp index 51c36ef22a..9bb0fc2de0 100644 --- a/engines/gob/sound.cpp +++ b/engines/gob/sound.cpp @@ -127,7 +127,7 @@ Snd::SoundDesc *Snd::loadSoundData(const char *path) { return sndDesc; } -void Snd::freeSoundData(Snd::SoundDesc *sndDesc) { +void Snd::freeSoundDesc(Snd::SoundDesc *sndDesc, bool freedata) { _vm->_mixer->stopHandle(sndDesc->handle); for (int i = 0; i < ARRAYSIZE(_loopingSounds); i++) { @@ -135,7 +135,9 @@ void Snd::freeSoundData(Snd::SoundDesc *sndDesc) { _loopingSounds[i] = NULL; } - delete[] sndDesc->data; + if (freedata) { + delete[] sndDesc->data; + } delete sndDesc; } diff --git a/engines/gob/sound.h b/engines/gob/sound.h index bb763ebca3..4433cde305 100644 --- a/engines/gob/sound.h +++ b/engines/gob/sound.h @@ -58,7 +58,10 @@ public: void playSample(SoundDesc *sndDesc, int16 repCount, int16 frequency); void playComposition(Snd::SoundDesc ** samples, int16 *composit, int16 freqVal) {;} void waitEndPlay(void) {;} - void freeSoundData(SoundDesc *sndDesc); + + // This deletes sndDesc and stops playing the sample. + // If freedata is set, it also delete[]s the sample data. + void freeSoundDesc(SoundDesc *sndDesc, bool freedata=true); protected: // TODO: This is a very primitive square wave generator. The only thing is |