aboutsummaryrefslogtreecommitdiff
path: root/engines/voyeur
diff options
context:
space:
mode:
authorPaul Gilbert2013-12-02 22:45:29 -0500
committerPaul Gilbert2013-12-02 22:45:29 -0500
commit805230e16364c5b4fbdb3f3450502ca59e2ba873 (patch)
tree5efe101362de8a4e34be55e208cbdbb2669247f1 /engines/voyeur
parent08d68be2dceb1d3d3029ea415a3316bb81a9fde4 (diff)
downloadscummvm-rg350-805230e16364c5b4fbdb3f3450502ca59e2ba873.tar.gz
scummvm-rg350-805230e16364c5b4fbdb3f3450502ca59e2ba873.tar.bz2
scummvm-rg350-805230e16364c5b4fbdb3f3450502ca59e2ba873.zip
VOYEUR: Fix for stuttering sound in animation playback
Diffstat (limited to 'engines/voyeur')
-rw-r--r--engines/voyeur/animation.cpp24
-rw-r--r--engines/voyeur/animation.h3
2 files changed, 22 insertions, 5 deletions
diff --git a/engines/voyeur/animation.cpp b/engines/voyeur/animation.cpp
index 4278d50d96..0f98dbbf63 100644
--- a/engines/voyeur/animation.cpp
+++ b/engines/voyeur/animation.cpp
@@ -50,7 +50,7 @@ bool RL2Decoder::loadStream(Common::SeekableReadStream *stream) {
// Add an audio track if sound is present
RL2AudioTrack *audioTrack = NULL;
if (_header._soundRate) {
- audioTrack = new RL2AudioTrack(_header, _soundType);
+ audioTrack = new RL2AudioTrack(_header, stream, _soundType);
addTrack(audioTrack);
}
@@ -211,8 +211,7 @@ const Graphics::Surface *RL2Decoder::RL2VideoTrack::decodeNextFrame() {
_fileStream->seek(_header._frameOffsets[_curFrame]);
// If there's any sound data, pass it to the audio track
- if (_header._frameSoundSizes[_curFrame] > 0 && _audioTrack)
- _audioTrack->queueSound(_fileStream, _header._frameSoundSizes[_curFrame]);
+ _fileStream->seek(_header._frameSoundSizes[_curFrame], SEEK_CUR);
// Decode the graphic data
if (_backSurface) {
@@ -321,9 +320,24 @@ void RL2Decoder::RL2VideoTrack::rl2DecodeFrameWithBackground() {
/*------------------------------------------------------------------------*/
-RL2Decoder::RL2AudioTrack::RL2AudioTrack(const RL2FileHeader &header, Audio::Mixer::SoundType soundType):
+RL2Decoder::RL2AudioTrack::RL2AudioTrack(const RL2FileHeader &header, Common::SeekableReadStream *stream, Audio::Mixer::SoundType soundType):
_header(header), _soundType(soundType) {
_audStream = createAudioStream();
+
+ // Add all the sound data for all the frames at once to avoid stuttering
+ for (int frameNumber = 0; frameNumber < header._numFrames; ++frameNumber) {
+ int offset = _header._frameOffsets[frameNumber];
+ int size = _header._frameSoundSizes[frameNumber];
+
+ byte *data = (byte *)malloc(size);
+ stream->seek(offset);
+ stream->read(data, size);
+ Common::MemoryReadStream *memoryStream = new Common::MemoryReadStream(data, size,
+ DisposeAfterUse::YES);
+
+ _audStream->queueAudioStream(Audio::makeRawStream(memoryStream, _header._rate,
+ Audio::FLAG_UNSIGNED, DisposeAfterUse::YES), DisposeAfterUse::YES);
+ }
}
RL2Decoder::RL2AudioTrack::~RL2AudioTrack() {
@@ -340,6 +354,8 @@ void RL2Decoder::RL2AudioTrack::queueSound(Common::SeekableReadStream *stream, i
_audStream->queueAudioStream(Audio::makeRawStream(memoryStream, _header._rate,
Audio::FLAG_UNSIGNED, DisposeAfterUse::YES), DisposeAfterUse::YES);
+ // _audioTrack->queueSound(_fileStream, _header._frameSoundSizes[_curFrame]);
+
} else {
delete stream;
}
diff --git a/engines/voyeur/animation.h b/engines/voyeur/animation.h
index c5991f49f0..53d24fc0c3 100644
--- a/engines/voyeur/animation.h
+++ b/engines/voyeur/animation.h
@@ -81,7 +81,8 @@ public:
private:
class RL2AudioTrack : public AudioTrack {
public:
- RL2AudioTrack(const RL2FileHeader &header, Audio::Mixer::SoundType soundType);
+ RL2AudioTrack(const RL2FileHeader &header, Common::SeekableReadStream *stream,
+ Audio::Mixer::SoundType soundType);
~RL2AudioTrack();
void queueSound(Common::SeekableReadStream *stream, int size);