From ce9f4c32159f2569400efa2ff5e34ec2dd9955ac Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Tue, 30 May 2023 14:49:17 -0500 Subject: [PATCH] LibVideo/PlaybackManager: Return duration zero when an error occurs Previously, we would unwrap the duration value even when it contained an error, causing an assertion failure. Later, we should change it to return the last known sample timestamp in the media data, allowing for example live-streamed video to have a semi-useful duration. In general, though, this is not used by players in the wild, so we can leave it for now. --- Userland/Libraries/LibVideo/PlaybackManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index a636b654b2..38cd804b17 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -118,8 +118,13 @@ Duration PlaybackManager::duration() auto demuxer_locker = Threading::MutexLocker(m_demuxer_mutex); m_demuxer->duration(); }); - if (duration_result.is_error()) + if (duration_result.is_error()) { dispatch_decoder_error(duration_result.release_error()); + // FIXME: We should determine the last sample that the demuxer knows is available and + // use that as the current duration. The duration may change if the demuxer doesn't + // know there is a fixed duration. + return Duration::zero(); + } return duration_result.release_value(); }