stop playing a sample before deleting the sample data

svn-id: r20902
This commit is contained in:
Willem Jan Palenstijn
2006-02-26 01:25:27 +00:00
parent 76962c3ce6
commit 06e02f6010
4 changed files with 15 additions and 7 deletions
+6 -3
View File
@@ -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) {
+1 -1
View File
@@ -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;
}
+4 -2
View File
@@ -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;
}
+4 -1
View File
@@ -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