MORTEVIELLE: Fix leak in playSong, refactor it a bit

This commit is contained in:
Strangerke 2013-08-05 00:13:57 +02:00
parent 0d2f812387
commit 80cc1700a7
2 changed files with 5 additions and 4 deletions

View File

@ -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())
;

View File

@ -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);
};