aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-07 17:04:01 +0000
committerJohannes Schickel2010-01-07 17:04:01 +0000
commita597e5fef93523436e60eca18997fb5ca5196345 (patch)
tree673cc525c81033c28ccbc4e5a7163f00e941f59b
parent771867fd1bd96470d788644072f4f6ad8beca640 (diff)
downloadscummvm-rg350-a597e5fef93523436e60eca18997fb5ca5196345.tar.gz
scummvm-rg350-a597e5fef93523436e60eca18997fb5ca5196345.tar.bz2
scummvm-rg350-a597e5fef93523436e60eca18997fb5ca5196345.zip
Make VagStream a RewindableAudioStream.
svn-id: r47132
-rw-r--r--engines/sword1/music.cpp2
-rw-r--r--engines/sword2/sound.cpp16
-rw-r--r--engines/tinsel/sound.cpp2
-rw-r--r--sound/vag.cpp10
-rw-r--r--sound/vag.h7
5 files changed, 18 insertions, 19 deletions
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index a82384659c..783900c598 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -252,7 +252,7 @@ bool MusicHandle::playPSX(uint16 id, bool loop) {
// 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;
diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp
index 3128bfed20..3d468ebba3 100644
--- a/engines/sword2/sound.cpp
+++ b/engines/sword2/sound.cpp
@@ -331,17 +331,19 @@ int32 Sound::playFx(Audio::SoundHandle *handle, byte *data, uint32 len, uint8 vo
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;
}
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index ece054138a..5d7bcfad72 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -108,7 +108,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
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);
diff --git a/sound/vag.cpp b/sound/vag.cpp
index 483ac36bb8..c4ff55efa2 100644
--- a/sound/vag.cpp
+++ b/sound/vag.cpp
@@ -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 @@ int VagStream::readBuffer(int16 *buffer, const int numSamples) {
_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;
}
}
diff --git a/sound/vag.h b/sound/vag.h
index 3bbda156e7..bd3b174729 100644
--- a/sound/vag.h
+++ b/sound/vag.h
@@ -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;