mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +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:
parent
1c1b750bff
commit
3c68a6684e
1 changed files with 5 additions and 0 deletions
|
@ -106,6 +106,11 @@ Time PlaybackManager::duration()
|
||||||
|
|
||||||
void PlaybackManager::on_decoder_error(DecoderError error)
|
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()) {
|
switch (error.category()) {
|
||||||
case DecoderErrorCategory::EndOfStream:
|
case DecoderErrorCategory::EndOfStream:
|
||||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "{}", error.string_literal());
|
dbgln_if(PLAYBACK_MANAGER_DEBUG, "{}", error.string_literal());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue