aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-08-09 15:36:21 +0200
committerBorja Lorente2016-08-19 16:29:15 +0200
commit7f533ff7df2e54efc01a44a838cd8f67ddf551b0 (patch)
treefd91d27891c0121d2dd1414cffffd7b4e20341b9
parentfd601f016f952f0a1b7fb4170fa05293813e7da5 (diff)
downloadscummvm-rg350-7f533ff7df2e54efc01a44a838cd8f67ddf551b0.tar.gz
scummvm-rg350-7f533ff7df2e54efc01a44a838cd8f67ddf551b0.tar.bz2
scummvm-rg350-7f533ff7df2e54efc01a44a838cd8f67ddf551b0.zip
MACVENTURE: Fix double free on sound
-rw-r--r--engines/macventure/macventure.cpp4
-rw-r--r--engines/macventure/sound.cpp15
2 files changed, 11 insertions, 8 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 8b947d5790..beee71aae5 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -634,8 +634,8 @@ void MacVentureEngine::playSounds(bool pause) {
}
}
if (pause && delay > 0) {
- warning("Sound pausing not yet tested. Pausing for %d", delay * 1000);
- g_system->delayMillis(delay * 1000);
+ warning("Sound pausing not yet tested. Pausing for %d", delay);
+ g_system->delayMillis(delay);
preparedToRun();
}
}
diff --git a/engines/macventure/sound.cpp b/engines/macventure/sound.cpp
index ea3b2d94ee..f05c88fcd6 100644
--- a/engines/macventure/sound.cpp
+++ b/engines/macventure/sound.cpp
@@ -42,7 +42,8 @@ SoundManager::~SoundManager(){
delete _container;
Common::HashMap<ObjID, SoundAsset*>::iterator it;
- for (it = _assets.begin(); it != _assets.end(); it++) {
+ Common::HashMap<ObjID, SoundAsset*>::iterator end = _assets.end();
+ for (it = _assets.begin(); it != end; it++) {
delete it->_value;
}
}
@@ -60,7 +61,7 @@ void SoundManager::ensureLoaded(ObjID sound) {
SoundAsset::SoundAsset(Container *container, ObjID id) :
_container(container), _id(id), _length(0), _frequency(1) {
-
+ debug("SoundAsset::SoundAsset(%d)", _id);
if (_container->getItemByteSize(_id) == 0)
warning("Trying to load an empty sound asset.");
@@ -99,17 +100,19 @@ SoundAsset::SoundAsset(Container *container, ObjID id) :
delete stream;
}
-SoundAsset::~SoundAsset() {}
+SoundAsset::~SoundAsset() {
+ debug("SoundAsset::~SoundAsset(%d)", _id);
+}
void SoundAsset::play(Audio::Mixer *mixer, Audio::SoundHandle *soundHandle) {
if (_data.size() == 0) return;
- Audio::AudioStream *sound = Audio::makeRawStream(&_data.front(), _length, _frequency, Audio::FLAG_UNSIGNED);
+ Audio::AudioStream *sound = Audio::makeRawStream(&_data.front(), _length, _frequency, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
mixer->playStream(Audio::Mixer::kPlainSoundType, soundHandle, sound);
}
uint32 SoundAsset::getPlayLength() {
-
- return _length / _frequency;
+ // Transform to milliseconds
+ return _length * 1000 / _frequency;
}
void SoundAsset::decode10(Common::SeekableReadStream *stream) {