[Scummvm-cvs-logs] SF.net SVN: scummvm:[47132] scummvm/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Thu Jan 7 18:04:01 CET 2010
Revision: 47132
http://scummvm.svn.sourceforge.net/scummvm/?rev=47132&view=rev
Author: lordhoto
Date: 2010-01-07 17:04:01 +0000 (Thu, 07 Jan 2010)
Log Message:
-----------
Make VagStream a RewindableAudioStream.
Modified Paths:
--------------
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/engines/sword2/sound.cpp
scummvm/trunk/engines/tinsel/sound.cpp
scummvm/trunk/sound/vag.cpp
scummvm/trunk/sound/vag.h
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2010-01-07 16:49:23 UTC (rev 47131)
+++ scummvm/trunk/engines/sword1/music.cpp 2010-01-07 17:04:01 UTC (rev 47132)
@@ -252,7 +252,7 @@
// not over file size
if ((size != 0) && (size != 0xffffffff) && ((int32)(offset + size) <= _file.size())) {
_file.seek(offset, SEEK_SET);
- _audioSource = new Audio::VagStream(_file.readStream(size), loop);
+ _audioSource = Audio::makeLoopingAudioStream(new Audio::VagStream(_file.readStream(size)), loop ? 0 : 1);
fadeUp();
} else {
_audioSource = NULL;
Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp 2010-01-07 16:49:23 UTC (rev 47131)
+++ scummvm/trunk/engines/sword2/sound.cpp 2010-01-07 17:04:01 UTC (rev 47132)
@@ -331,17 +331,19 @@
return RDERR_FXALREADYOPEN;
Common::MemoryReadStream *stream = new Common::MemoryReadStream(data, len);
- Audio::AudioStream *input = 0;
+ Audio::RewindableAudioStream *input = 0;
- if (Sword2Engine::isPsx()) {
- input = new Audio::VagStream(stream, loop);
- } else {
- input = Audio::makeLoopingAudioStream(Audio::makeWAVStream(stream, true), loop ? 0 : 1);
- }
+ if (Sword2Engine::isPsx())
+ input = new Audio::VagStream(stream);
+ else
+ input = Audio::makeWAVStream(stream, true);
assert(input);
- _vm->_mixer->playInputStream(soundType, handle, input, -1, vol, pan, true, false, isReverseStereo());
+ if (loop)
+ _vm->_mixer->playInputStreamLooping(soundType, handle, input, 0, -1, vol, pan, true, false, isReverseStereo());
+ else
+ _vm->_mixer->playInputStream(soundType, handle, input, -1, vol, pan, true, false, isReverseStereo());
return RD_OK;
}
Modified: scummvm/trunk/engines/tinsel/sound.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sound.cpp 2010-01-07 16:49:23 UTC (rev 47131)
+++ scummvm/trunk/engines/tinsel/sound.cpp 2010-01-07 17:04:01 UTC (rev 47132)
@@ -108,7 +108,7 @@
if (TinselV1PSX) {
// Read the stream and create a VAG Audio stream
- Audio::AudioStream *vagStream = new Audio::VagStream(_sampleStream.readStream(sampleLen), false, 44100);
+ Audio::AudioStream *vagStream = new Audio::VagStream(_sampleStream.readStream(sampleLen), 44100);
// FIXME: Should set this in a different place ;)
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);
Modified: scummvm/trunk/sound/vag.cpp
===================================================================
--- scummvm/trunk/sound/vag.cpp 2010-01-07 16:49:23 UTC (rev 47131)
+++ scummvm/trunk/sound/vag.cpp 2010-01-07 17:04:01 UTC (rev 47132)
@@ -27,11 +27,10 @@
namespace Audio {
-VagStream::VagStream(Common::SeekableReadStream *stream, bool loop, int rate) : _stream(stream) {
+VagStream::VagStream(Common::SeekableReadStream *stream, int rate) : _stream(stream) {
_samplesRemaining = 0;
_predictor = 0;
_s1 = _s2 = 0.0;
- _loop = loop;
_rate = rate;
}
@@ -109,17 +108,16 @@
_samplesRemaining = 28 - i;
}
- if (_loop && _stream->eos())
- rewind();
-
return samplesDecoded;
}
-void VagStream::rewind() {
+bool VagStream::rewind() {
_stream->seek(0);
_samplesRemaining = 0;
_predictor = 0;
_s1 = _s2 = 0.0;
+
+ return true;
}
}
Modified: scummvm/trunk/sound/vag.h
===================================================================
--- scummvm/trunk/sound/vag.h 2010-01-07 16:49:23 UTC (rev 47131)
+++ scummvm/trunk/sound/vag.h 2010-01-07 17:04:01 UTC (rev 47132)
@@ -38,21 +38,20 @@
namespace Audio {
-class VagStream : public Audio::AudioStream {
+class VagStream : public Audio::RewindableAudioStream {
public:
- VagStream(Common::SeekableReadStream *stream, bool loop = false, int rate = 11025);
+ VagStream(Common::SeekableReadStream *stream, int rate = 11025);
~VagStream();
bool isStereo() const { return false; }
bool endOfData() const { return _stream->pos() == _stream->size(); }
int getRate() const { return _rate; }
int readBuffer(int16 *buffer, const int numSamples);
- void rewind();
+ bool rewind();
private:
Common::SeekableReadStream *_stream;
- bool _loop;
byte _predictor;
double _samples[28];
byte _samplesRemaining;
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