From 620fa7c6414e98949537b9b759c65ea336fb64d0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 16 Oct 2009 18:32:20 +0000 Subject: Override getAudioLag() in the AviDecoder (blatantly borrowed from the SmackerDecoder). svn-id: r45172 --- graphics/video/avi_decoder.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'graphics/video/avi_decoder.cpp') diff --git a/graphics/video/avi_decoder.cpp b/graphics/video/avi_decoder.cpp index fa5494d9b9..a3180edeee 100644 --- a/graphics/video/avi_decoder.cpp +++ b/graphics/video/avi_decoder.cpp @@ -361,6 +361,27 @@ bool AviDecoder::decodeNextFrame() { return _videoInfo.currentFrame < _videoInfo.frameCount; } +int32 AviDecoder::getAudioLag() { + if (!_fileStream) + return 0; + + int32 frameDelay = getFrameDelay(); + int32 videoTime = _videoInfo.currentFrame * frameDelay; + int32 audioTime; + + if (!_audStream) { + /* No audio. + Calculate the lag by how much time has gone by since the first frame + and how much time *should* have passed. + */ + + audioTime = (g_system->getMillis() - _videoInfo.startTime) * 100; + } else + audioTime = (((int32)_mixer->getSoundElapsedTime(*_audHandle)) * 100); + + return videoTime - audioTime; +} + Codec *AviDecoder::createCodec() { switch (_vidsHeader.streamHandler) { case ID_CRAM: -- cgit v1.2.3