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.
This commit is contained in:
Thierry Crozat 2013-08-04 12:56:15 +01:00
parent fbb1137f94
commit deef0b955c

View File

@ -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) {