From ca83ecd8c22c132da3f9b8963ffb76702692a272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Andersson?= Date: Sat, 24 Jan 2015 14:54:25 +0100 Subject: [PATCH] ZVISION: Fix lag at beginning of cutscenes We have to update _curChunk when decoding audio, otherwise it will decode the entire audio track on the first frame. For the ZGI intro this would take 700-800 ms, and since the audio started playing before the video it looked to me as if it had to play the first bit faster to catch up. Thanks to fuzzie for setting me on the right track with an off-hand remark about the Zork AVI decoder (I was looking at the standard AVI decoder), and for finding the cause a few seconds before I did. --- engines/zvision/video/zork_avi_decoder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 5618250d790..abf48543c97 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -39,6 +39,7 @@ Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDec } void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { + bool updateCurChunk = true; if (_audStream) { if (_wvInfo.tag == kWaveFormatZorkPCM) { assert(_wvInfo.size == 8); @@ -54,9 +55,17 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); } } else { + updateCurChunk = false; AVIAudioTrack::queueSound(stream); } } + + // The superclass always updates _curChunk, whether or not audio has + // been queued, so we should do that too. Unless the superclass already + // has done it for us. + if (updateCurChunk) { + _curChunk++; + } } void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() {