diff options
-rw-r--r-- | graphics/video/avi_decoder.cpp | 21 | ||||
-rw-r--r-- | graphics/video/avi_decoder.h | 3 |
2 files changed, 23 insertions, 1 deletions
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: diff --git a/graphics/video/avi_decoder.h b/graphics/video/avi_decoder.h index 85500302d0..bfeab02346 100644 --- a/graphics/video/avi_decoder.h +++ b/graphics/video/avi_decoder.h @@ -188,8 +188,9 @@ public: void closeFile(); bool decodeNextFrame(); - + int32 getAudioLag(); int32 getFrameRate() { return _vidsHeader.rate / _vidsHeader.scale; } + private: Audio::Mixer *_mixer; BITMAPINFOHEADER _bmInfo; |