diff options
author | Matthew Hoops | 2012-07-25 00:39:21 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-07-25 00:39:21 -0400 |
commit | 09f1519d6d369e7e59102b53cfb56a731bff99fb (patch) | |
tree | 9a594b5f3ceca2a9db17de965258eab0b0aac389 | |
parent | 3117e4a8ff12c3a2ba4f2d4c69e8539040d49eb0 (diff) | |
download | scummvm-rg350-09f1519d6d369e7e59102b53cfb56a731bff99fb.tar.gz scummvm-rg350-09f1519d6d369e7e59102b53cfb56a731bff99fb.tar.bz2 scummvm-rg350-09f1519d6d369e7e59102b53cfb56a731bff99fb.zip |
VIDEO: Stop and restart tracks when seeking/rewinding
-rw-r--r-- | video/video_decoder.cpp | 32 | ||||
-rw-r--r-- | video/video_decoder.h | 4 |
2 files changed, 30 insertions, 6 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index 1461f5dc3d..355c94abb1 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -256,12 +256,18 @@ bool AdvancedVideoDecoder::rewind() { _needsRewind = false; - // TODO: Pause status + // Stop all tracks so they can be rewound + if (_isPlaying) + stopAllTracks(); for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) if (!(*it)->rewind()) return false; + // Now that we've rewound, start all tracks again + if (_isPlaying) + startAllTracks(); + _audioStartOffset = 0; _startTime = g_system->getMillis(); return true; @@ -284,12 +290,18 @@ bool AdvancedVideoDecoder::seek(const Audio::Timestamp &time) { _needsRewind = false; - // TODO: Pause status + // Stop all tracks so they can be seeked + if (_isPlaying) + stopAllTracks(); for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) if (!(*it)->seek(time)) return false; + // Now that we've seeked, start all tracks again + if (_isPlaying) + startAllTracks(); + _audioStartOffset = time; _startTime = g_system->getMillis() - time.msecs(); return true; @@ -307,8 +319,7 @@ void AdvancedVideoDecoder::start() { if (_needsRewind) rewind(); - for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) - (*it)->start(); + startAllTracks(); } void AdvancedVideoDecoder::stop() { @@ -321,8 +332,7 @@ void AdvancedVideoDecoder::stop() { _palette = 0; _dirtyPalette = false; - for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) - (*it)->stop(); + stopAllTracks(); // Also reset the pause state. _pauseLevel = 0; @@ -584,6 +594,16 @@ const AdvancedVideoDecoder::VideoTrack *AdvancedVideoDecoder::findNextVideoTrack return bestTrack; } +void AdvancedVideoDecoder::startAllTracks() { + for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) + (*it)->start(); +} + +void AdvancedVideoDecoder::stopAllTracks() { + for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) + (*it)->stop(); +} + ////////////////////////////////////////////// ///////////////// DEPRECATED ///////////////// ////////////////////////////////////////////// diff --git a/video/video_decoder.h b/video/video_decoder.h index 616d6c4f96..c77fb44dfe 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -670,6 +670,10 @@ private: // Palette settings from individual tracks mutable bool _dirtyPalette; const byte *_palette; + + // Internal helper functions + void stopAllTracks(); + void startAllTracks(); }; /** |