diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-27 00:45:14 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-27 10:45:52 +0100 |
commit | 3c68a6684ea0bedbc5e93d9cfc9b1c3033ff58b2 (patch) | |
tree | b72f64106abd9b6e34a8e84a67e44cf1df7cc3f2 | |
parent | 1c1b750bff770e126d79e6e71c11223309838b92 (diff) | |
download | serenity-3c68a6684ea0bedbc5e93d9cfc9b1c3033ff58b2.zip |
LibVideo: Don't crash when a decoder error is encountered while seeking
When errors are encountered by PlaybackManager, it attempts to switch
states to either Stopped or Corrupted. However, that causes it to set
the last presentation media time to the current playback time while the
last presentation time is unexpectedly negative because the seek never
ended.
Ending the seek before the state changes to Stopped or Corrupted
prevents this situation from happening.
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 17d2c52f33..2332f69494 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -106,6 +106,11 @@ Time PlaybackManager::duration() void PlaybackManager::on_decoder_error(DecoderError error) { + // If we don't switch to playing/paused before stopping/becoming corrupted, the player will crash + // due to the invalid playback time. + if (is_seeking()) + end_seek(); + switch (error.category()) { case DecoderErrorCategory::EndOfStream: dbgln_if(PLAYBACK_MANAGER_DEBUG, "{}", error.string_literal()); |