[Scummvm-cvs-logs] SF.net SVN: scummvm:[47129] scummvm/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu Jan 7 17:34:56 CET 2010
Revision: 47129
http://scummvm.svn.sourceforge.net/scummvm/?rev=47129&view=rev
Author: lordhoto
Date: 2010-01-07 16:34:56 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Make makeWAVStream return a RewindableAudioStream.
Modified Paths:
--------------
scummvm/trunk/engines/agos/sound.cpp
scummvm/trunk/engines/sci/sound/audio.cpp
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/engines/sword2/sound.cpp
scummvm/trunk/engines/tucker/resource.cpp
scummvm/trunk/engines/tucker/sequences.cpp
scummvm/trunk/sound/wave.cpp
scummvm/trunk/sound/wave.h
Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/agos/sound.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -783,12 +783,15 @@
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() {
Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/sci/sound/audio.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -230,7 +230,7 @@
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) {
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/sword1/music.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -215,7 +215,7 @@
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) {
Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/sword2/sound.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -336,7 +336,7 @@
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);
Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/tucker/resource.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -946,11 +946,12 @@
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));
Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/engines/tucker/sequences.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -604,7 +604,7 @@
break;
case kAnimationSoundTypeWAV:
case kAnimationSoundTypeLoopingWAV:
- stream = Audio::makeWAVStream(&f, true, type == kAnimationSoundTypeLoopingWAV);
+ stream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&f, true), type == kAnimationSoundTypeLoopingWAV ? 0 : 1);
break;
}
Modified: scummvm/trunk/sound/wave.cpp
===================================================================
--- scummvm/trunk/sound/wave.cpp 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/sound/wave.cpp 2010-01-07 16:34:56 UTC (rev 47129)
@@ -161,7 +161,7 @@
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 @@
}
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 @@
// 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);
}
Modified: scummvm/trunk/sound/wave.h
===================================================================
--- scummvm/trunk/sound/wave.h 2010-01-07 16:18:03 UTC (rev 47128)
+++ scummvm/trunk/sound/wave.h 2010-01-07 16:34:56 UTC (rev 47129)
@@ -44,7 +44,7 @@
namespace Audio {
-class AudioStream;
+class RewindableAudioStream;
/**
* Try to load a WAVE from the given seekable stream. Returns true if
@@ -70,13 +70,11 @@
*
* @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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list