diff options
-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(); }; /** |