TWINE: plug memory leaks

This commit is contained in:
Martin Gerhardy 2020-11-17 17:37:53 +01:00
parent 5d9ffc23b7
commit f037bddc53
3 changed files with 7 additions and 0 deletions

View File

@ -41,6 +41,10 @@ namespace TwinE {
Sound::Sound(TwinEEngine *engine) : _engine(engine) {
}
Sound::~Sound() {
_engine->_system->getMixer()->stopAll();
}
void Sound::setSamplePosition(int32 chan, int32 x, int32 y, int32 z) {
int32 distance;
distance = ABS(_engine->_movements->getDistance3D(_engine->_grid->newCameraX << 9, _engine->_grid->newCameraY << 8, _engine->_grid->newCameraZ << 9, x, y, z));
@ -130,6 +134,7 @@ bool Sound::playSample(int channelIdx, int index, uint8 *sampPtr, int32 sampSize
Audio::SeekableAudioStream *audioStream = Audio::makeVOCStream(stream, DisposeAfterUse::YES);
if (audioStream == nullptr) {
warning("Failed to create audio stream for %s", name);
delete stream;
return false;
}
_engine->_system->getMixer()->playStream(soundType, &samplesPlaying[channelIdx], audioStream, index);

View File

@ -71,6 +71,7 @@ private:
public:
Sound(TwinEEngine *engine);
~Sound();
/**
* Play FLA movie samples

View File

@ -128,6 +128,7 @@ TwinEEngine::~TwinEEngine() {
delete _interface;
delete _menu;
delete _flaMovies;
delete _menuOptions;
delete _music;
delete _redraw;
delete _renderer;