aboutsummaryrefslogtreecommitdiff
path: root/engines/mortevielle
diff options
context:
space:
mode:
authorThierry Crozat2013-08-04 12:56:15 +0100
committerThierry Crozat2013-08-04 12:56:15 +0100
commitdeef0b955ca95c6c4141668f60fd0bccc0b9949d (patch)
treefb3f8d55b5f900fc1ecb8af9145415146dff5e74 /engines/mortevielle
parentfbb1137f946e929b675e181d1cccfabf46c5b83a (diff)
downloadscummvm-rg350-deef0b955ca95c6c4141668f60fd0bccc0b9949d.tar.gz
scummvm-rg350-deef0b955ca95c6c4141668f60fd0bccc0b9949d.tar.bz2
scummvm-rg350-deef0b955ca95c6c4141668f60fd0bccc0b9949d.zip
MORTEVIELLE: Fix crash in sound mixer when closing the engine
This was due to the _speakerHandle being reused between its initialisation in the SoundManager constructor and the destructor causing it to have a wrong value when trying (and failing) to stop the PCSpeaker channel in the mixer before deleting the stream.
Diffstat (limited to 'engines/mortevielle')
-rw-r--r--engines/mortevielle/sound.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp
index 95da5c0e01..d95b12da3c 100644
--- a/engines/mortevielle/sound.cpp
+++ b/engines/mortevielle/sound.cpp
@@ -187,10 +187,13 @@ void SoundManager::playNote(int frequency, int32 length) {
void SoundManager::playSong(const byte* buf, int size) {
Audio::AudioStream *stream = Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ Audio::SoundHandle songHandle;
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &songHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
- while (_mixer->isSoundHandleActive(_speakerHandle) && !_vm->keyPressed() && !_vm->_mouseClick && !_vm->shouldQuit())
+ while (_mixer->isSoundHandleActive(songHandle) && !_vm->keyPressed() && !_vm->_mouseClick && !_vm->shouldQuit())
;
+ // In case the handle is still active, stop it.
+ _mixer->stopHandle(songHandle);
}
void SoundManager::setParent(MortevielleEngine *vm) {