diff options
author | Max Horn | 2010-01-20 12:43:59 +0000 |
---|---|---|
committer | Max Horn | 2010-01-20 12:43:59 +0000 |
commit | 7799dc3614b2987ced46905edf9eb6c46cbcd13a (patch) | |
tree | ea73082b91ca5302348057429c5c946fb08eb2fa /engines/saga | |
parent | f5f6faaf971b4e900c6e14c14bebd465952ca8ca (diff) | |
download | scummvm-rg350-7799dc3614b2987ced46905edf9eb6c46cbcd13a.tar.gz scummvm-rg350-7799dc3614b2987ced46905edf9eb6c46cbcd13a.tar.bz2 scummvm-rg350-7799dc3614b2987ced46905edf9eb6c46cbcd13a.zip |
SAGA: Change Sound::playSoundBuffer to enable looping for all sound formats
svn-id: r47405
Diffstat (limited to 'engines/saga')
-rw-r--r-- | engines/saga/sound.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index cf647d0c53..5bbe89e915 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -67,44 +67,42 @@ SndHandle *Sound::getHandle() { void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffer, int volume, sndHandleType handleType, bool loop) { - Audio::AudioStream *stream = 0; + Audio::RewindableAudioStream *stream = 0; Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ? Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType; if (!buffer.isCompressed) { - stream = Audio::makeLoopingAudioStream( - Audio::makeRawMemoryStream(buffer.buffer, buffer.size, DisposeAfterUse::YES, buffer.frequency, buffer.flags), - loop ? 0 : 1); + stream = Audio::makeRawMemoryStream(buffer.buffer, buffer.size, DisposeAfterUse::YES, buffer.frequency, buffer.flags); } else { + Common::SeekableReadStream *memStream = new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES); - // TODO / FIXME: It seems we don't loop compressed audio at all, but do loop uncompressed data. - // Is that intentional? Seems odd... switch (buffer.soundType) { #ifdef USE_MAD - case kSoundMP3: - stream = Audio::makeMP3Stream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); - break; + case kSoundMP3: + stream = Audio::makeMP3Stream(memStream, DisposeAfterUse::YES); + break; #endif #ifdef USE_VORBIS - case kSoundOGG: - stream = Audio::makeVorbisStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); - break; + case kSoundOGG: + stream = Audio::makeVorbisStream(memStream, DisposeAfterUse::YES); + break; #endif #ifdef USE_FLAC - case kSoundFLAC: - stream = Audio::makeFlacStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); - break; + case kSoundFLAC: + stream = Audio::makeFlacStream(memStream, DisposeAfterUse::YES); + break; #endif - default: - // Unknown compression, ignore sample - warning("Unknown compression, ignoring sound"); - break; + default: + // Unknown compression, ignore sample + delete memStream; + warning("Unknown compression, ignoring sound"); + break; } } if (stream != NULL) - _mixer->playInputStream(soundType, handle, stream, -1, volume); + _mixer->playInputStream(soundType, handle, Audio::makeLoopingAudioStream(stream, loop ? 0 : 1), -1, volume); } void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) { |