From 80cc1700a7a3e151f25a45dcad868b4d5b62d334 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 5 Aug 2013 00:13:57 +0200 Subject: MORTEVIELLE: Fix leak in playSong, refactor it a bit --- engines/mortevielle/sound.cpp | 7 ++++--- engines/mortevielle/sound.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/mortevielle') diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp index 042097f52c..bfdadaa048 100644 --- a/engines/mortevielle/sound.cpp +++ b/engines/mortevielle/sound.cpp @@ -185,10 +185,11 @@ void SoundManager::playNote(int frequency, int32 length) { } -void SoundManager::playSong(const byte* buf, int size, int loops) { - Audio::AudioStream *stream = Audio::makeLoopingAudioStream(Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS), loops); +void SoundManager::playSong(const byte* buf, uint size, uint loops) { + Audio::SeekableAudioStream *raw = Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS, DisposeAfterUse::NO); + Audio::AudioStream *stream = Audio::makeLoopingAudioStream(raw, loops); Audio::SoundHandle songHandle; - _mixer->playStream(Audio::Mixer::kSFXSoundType, &songHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + _mixer->playStream(Audio::Mixer::kSFXSoundType, &songHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); while (_mixer->isSoundHandleActive(songHandle) && !_vm->keyPressed() && !_vm->_mouseClick && !_vm->shouldQuit()) ; diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h index ee6aaff4ad..1f9e0d9c4d 100644 --- a/engines/mortevielle/sound.h +++ b/engines/mortevielle/sound.h @@ -106,7 +106,7 @@ public: void playNote(int frequency, int32 length); int decodeMusic(const byte *PSrc, byte *PDest, int size); - void playSong(const byte *buf, int size, int loops = 1); + void playSong(const byte *buf, uint usize, uint loops); void litph(tablint &t, int typ, int tempo); }; -- cgit v1.2.3