mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
stop playing a sample before deleting the sample data
svn-id: r20902
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user