diff options
author | Johannes Schickel | 2010-01-07 16:34:56 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-07 16:34:56 +0000 |
commit | d5fe29c3c949fda84a5a7a276160d57e646fc952 (patch) | |
tree | ba643bf1510a6fd061500abef7f08d432bbc7693 | |
parent | ca5e1379452f7777fd032baeb342ce88634d1836 (diff) | |
download | scummvm-rg350-d5fe29c3c949fda84a5a7a276160d57e646fc952.tar.gz scummvm-rg350-d5fe29c3c949fda84a5a7a276160d57e646fc952.tar.bz2 scummvm-rg350-d5fe29c3c949fda84a5a7a276160d57e646fc952.zip |
Make makeWAVStream return a RewindableAudioStream.
svn-id: r47129
-rw-r--r-- | engines/agos/sound.cpp | 7 | ||||
-rw-r--r-- | engines/sci/sound/audio.cpp | 2 | ||||
-rw-r--r-- | engines/sword1/music.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/sound.cpp | 2 | ||||
-rw-r--r-- | engines/tucker/resource.cpp | 3 | ||||
-rw-r--r-- | engines/tucker/sequences.cpp | 2 | ||||
-rw-r--r-- | sound/wave.cpp | 9 | ||||
-rw-r--r-- | sound/wave.h | 10 |
8 files changed, 18 insertions, 19 deletions
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp index ac965ac65f..d929574ac6 100644 --- a/engines/agos/sound.cpp +++ b/engines/agos/sound.cpp @@ -783,12 +783,15 @@ void Sound::playVoiceData(byte *soundData, uint sound) { void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) { int size = READ_LE_UINT32(soundData + 4); Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, size); - Audio::AudioStream *sndStream = Audio::makeWAVStream(stream, true, loop); + Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, true); convertVolume(vol); convertPan(pan); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, sndStream, -1, vol, pan); + if (loop) + _mixer->playInputStreamLooping(Audio::Mixer::kSFXSoundType, handle, sndStream, 0, -1, vol, pan); + else + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, sndStream, -1, vol, pan); } void Sound::stopSfx5() { diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp index 801864265f..bfc1fed330 100644 --- a/engines/sci/sound/audio.cpp +++ b/engines/sci/sound/audio.cpp @@ -230,7 +230,7 @@ Audio::AudioStream* AudioPlayer::getAudioStream(uint32 number, uint32 volume, in if (memcmp(audioRes->data, "RIFF", 4) == 0) { // WAVE detected Common::MemoryReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, Common::DisposeAfterUse::NO); - audioStream = Audio::makeWAVStream(waveStream, true, false); + audioStream = Audio::makeWAVStream(waveStream, true); } } if (!audioStream) { diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp index 67ea0bf376..a82384659c 100644 --- a/engines/sword1/music.cpp +++ b/engines/sword1/music.cpp @@ -215,7 +215,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.wav", fileBase); if (_file.open(fileName)) - _audioSource = Audio::makeWAVStream(&_file, false, loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&_file, false), loop ? 0 : 1); } if (!_audioSource) { diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp index c5212d20c2..3128bfed20 100644 --- a/engines/sword2/sound.cpp +++ b/engines/sword2/sound.cpp @@ -336,7 +336,7 @@ int32 Sound::playFx(Audio::SoundHandle *handle, byte *data, uint32 len, uint8 vo if (Sword2Engine::isPsx()) { input = new Audio::VagStream(stream, loop); } else { - input = Audio::makeWAVStream(stream, true, loop); + input = Audio::makeLoopingAudioStream(Audio::makeWAVStream(stream, true), loop ? 0 : 1); } assert(input); diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 8bc6e2c8e3..c8f2448980 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -946,11 +946,12 @@ void TuckerEngine::loadSound(Audio::Mixer::SoundType type, int num, int volume, snprintf(fileName, sizeof(fileName), fmt, num); Common::File *f = new Common::File; if (f->open(fileName)) { - stream = Audio::makeWAVStream(f, true, loop); + stream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(f, true), loop ? 0 : 1); } else { delete f; } } + if (stream) { _mixer->stopHandle(*handle); _mixer->playInputStream(type, handle, stream, -1, scaleMixerVolume(volume, kMaxSoundVolume)); diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 86962d7a31..ed31778209 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -604,7 +604,7 @@ Audio::AudioStream *AnimationSequencePlayer::loadSound(int index, AnimationSound break; case kAnimationSoundTypeWAV: case kAnimationSoundTypeLoopingWAV: - stream = Audio::makeWAVStream(&f, true, type == kAnimationSoundTypeLoopingWAV); + stream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&f, true), type == kAnimationSoundTypeLoopingWAV ? 0 : 1); break; } diff --git a/sound/wave.cpp b/sound/wave.cpp index bcae1b7f10..a625d18d90 100644 --- a/sound/wave.cpp +++ b/sound/wave.cpp @@ -161,7 +161,7 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, return true; } -AudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfterUse, bool loop) { +RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfterUse) { int size, rate; byte flags; uint16 type; @@ -174,9 +174,9 @@ AudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfter } if (type == 17) // MS IMA ADPCM - return makeLoopingAudioStream(makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign), loop ? 0 : 1); + return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign); else if (type == 2) // MS ADPCM - return makeLoopingAudioStream(makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign), loop ? 0 : 1); + return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign); // Raw PCM. Just read everything at once. // TODO: More elegant would be to wrap the stream. @@ -189,9 +189,6 @@ AudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfter // Since we allocated our own buffer for the data, we must set the autofree flag. flags |= Audio::Mixer::FLAG_AUTOFREE; - - if (loop) - flags |= Audio::Mixer::FLAG_LOOP; return makeLinearInputStream(data, size, rate, flags, 0, 0); } diff --git a/sound/wave.h b/sound/wave.h index b89d87ae4b..542c38a31d 100644 --- a/sound/wave.h +++ b/sound/wave.h @@ -44,7 +44,7 @@ namespace Common { class SeekableReadStream; } namespace Audio { -class AudioStream; +class RewindableAudioStream; /** * Try to load a WAVE from the given seekable stream. Returns true if @@ -70,13 +70,11 @@ extern bool loadWAVFromStream( * * @param stream the SeekableReadStream from which to read the WAVE data * @param disposeAfterUse whether to delete the stream after use - * @param loop whether to loop the sound (infinitely) - * @return a new AudioStream, or NULL, if an error occured + * @return a new RewindableAudioStream, or NULL, if an error occured */ -AudioStream *makeWAVStream( +RewindableAudioStream *makeWAVStream( Common::SeekableReadStream *stream, - bool disposeAfterUse = false, - bool loop = false); + bool disposeAfterUse = false); } // End of namespace Audio |