1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:37:34 +00:00

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.
This commit is contained in:
Zaggy1024 2022-11-27 00:45:14 -06:00 committed by Andreas Kling
parent 1c1b750bff
commit 3c68a6684e

View file

@ -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());