From d925d2c2cec380ff5422a6c737a8f7ee49085fd7 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Thu, 4 Aug 2016 17:11:13 +0200 Subject: MACVENTURE: Fix segfault with death sound --- engines/macventure/sound.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/macventure') diff --git a/engines/macventure/sound.cpp b/engines/macventure/sound.cpp index 97fe3c6132..0f9ea43afe 100644 --- a/engines/macventure/sound.cpp +++ b/engines/macventure/sound.cpp @@ -59,7 +59,7 @@ void SoundManager::ensureLoaded(ObjID sound) { } SoundAsset::SoundAsset(Container *container, ObjID id) : - _container(container), _id(id) { + _container(container), _id(id), _length(0), _frequency(1) { if (_container->getItemByteSize(_id) == 0) warning("Trying to load an empty sound asset."); @@ -93,6 +93,7 @@ SoundAsset::SoundAsset(Container *container, ObjID id) : break; default: warning("Unrecognized sound type: %x", type); + break; } delete stream; @@ -101,11 +102,13 @@ SoundAsset::SoundAsset(Container *container, ObjID id) : SoundAsset::~SoundAsset() {} 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); mixer->playStream(Audio::Mixer::kPlainSoundType, soundHandle, sound); } uint32 SoundAsset::getPlayLength() { + return _length / _frequency; } -- cgit v1.2.3