From 802873d3231a665d13d1f690bd9c780f7f7b7fb4 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 16 Oct 2011 22:27:51 -0400 Subject: VIDEO: Fix QuickTime audio track ends Fixes videos where the audio track length is smaller than the video track length. --- video/qt_decoder.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 74bf533e62..058dd6b489 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -298,9 +298,17 @@ bool QuickTimeDecoder::endOfVideo() const { } uint32 QuickTimeDecoder::getElapsedTime() const { - if (_audStream) - return g_system->getMixer()->getSoundElapsedTime(_audHandle) + _audioStartOffset.msecs(); + if (_audStream) { + // Use the audio time if present and the audio track's time is less than the + // total length of the audio track. The audio track can end before the video + // track, so we need to fall back on the getMillis() time tracking in that + // case. + uint32 time = g_system->getMixer()->getSoundElapsedTime(_audHandle) + _audioStartOffset.msecs(); + if (time < _tracks[_audioTrackIndex]->duration * 1000 / _tracks[_audioTrackIndex]->timeScale) + return time; + } + // Just use time elapsed since the beginning return SeekableVideoDecoder::getElapsedTime(); } -- cgit v1.2.3