aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2012-08-07 14:24:32 -0400
committerMatthew Hoops2012-08-07 14:24:32 -0400
commit220ca52f4329ad3c1344c38e23280fde4570bd89 (patch)
treed01454c88faada4d44e688f1da7b99b67ea09225
parentdd10e7191e4b373513e5a6fa73daa6312bd81f62 (diff)
downloadscummvm-rg350-220ca52f4329ad3c1344c38e23280fde4570bd89.tar.gz
scummvm-rg350-220ca52f4329ad3c1344c38e23280fde4570bd89.tar.bz2
scummvm-rg350-220ca52f4329ad3c1344c38e23280fde4570bd89.zip
VIDEO: Fix getTime() when a video is not playing
-rw-r--r--video/video_decoder.cpp20
-rw-r--r--video/video_decoder.h2
2 files changed, 14 insertions, 8 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 84ce8144a0..44b05c4345 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -102,6 +102,7 @@ AdvancedVideoDecoder::AdvancedVideoDecoder() {
_audioBalance = 0;
_pauseLevel = 0;
_needsUpdate = false;
+ _lastTimeChange = 0;
// Find the best format for output
_defaultHighColorFormat = g_system->getScreenFormat();
@@ -126,6 +127,7 @@ void AdvancedVideoDecoder::close() {
_audioBalance = 0;
_pauseLevel = 0;
_needsUpdate = false;
+ _lastTimeChange = 0;
}
bool AdvancedVideoDecoder::isVideoLoaded() const {
@@ -201,6 +203,9 @@ uint32 AdvancedVideoDecoder::getFrameCount() const {
}
uint32 AdvancedVideoDecoder::getTime() const {
+ if (!isPlaying())
+ return _lastTimeChange.msecs();
+
if (isPaused())
return _pauseStartTime - _startTime;
@@ -210,7 +215,7 @@ uint32 AdvancedVideoDecoder::getTime() const {
uint32 time = ((const AudioTrack *)*it)->getRunningTime();
if (time != 0)
- return time + _audioStartOffset.msecs();
+ return time + _lastTimeChange.msecs();
}
}
}
@@ -278,7 +283,7 @@ bool AdvancedVideoDecoder::rewind() {
if (isPlaying())
startAudio();
- _audioStartOffset = 0;
+ _lastTimeChange = 0;
_startTime = g_system->getMillis();
resetPauseStartTime();
return true;
@@ -313,7 +318,7 @@ bool AdvancedVideoDecoder::seek(const Audio::Timestamp &time) {
if (isPlaying())
startAudio();
- _audioStartOffset = time;
+ _lastTimeChange = time;
_startTime = g_system->getMillis() - time.msecs();
resetPauseStartTime();
_needsUpdate = true;
@@ -326,7 +331,7 @@ void AdvancedVideoDecoder::start() {
_isPlaying = true;
_startTime = g_system->getMillis();
- _audioStartOffset = 0;
+ _lastTimeChange = 0;
// If someone previously called stop(), we'll rewind it.
if (_needsRewind)
@@ -341,7 +346,6 @@ void AdvancedVideoDecoder::stop() {
_isPlaying = false;
_startTime = 0;
- _audioStartOffset = 0;
_palette = 0;
_dirtyPalette = false;
_needsUpdate = false;
@@ -354,10 +358,12 @@ void AdvancedVideoDecoder::stop() {
// If this is a rewindable video, don't close it too. We'll just rewind() the video
// the next time someone calls start(). Otherwise, since it can't be rewound, we
// just close it.
- if (isRewindable())
+ if (isRewindable()) {
+ _lastTimeChange = getTime();
_needsRewind = true;
- else
+ } else {
close();
+ }
}
Audio::Timestamp AdvancedVideoDecoder::getDuration() const {
diff --git a/video/video_decoder.h b/video/video_decoder.h
index ad9825cb25..26078d5750 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -773,7 +773,7 @@ private:
// Current playback status
bool _isPlaying, _needsRewind, _needsUpdate;
- Audio::Timestamp _audioStartOffset;
+ Audio::Timestamp _lastTimeChange;
// Palette settings from individual tracks
mutable bool _dirtyPalette;