diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2023-04-12 00:42:14 -0500 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-04-14 12:05:52 +0100 |
commit | e391f18e9e813443ba4c6aead2041a1c01b2227a (patch) | |
tree | 8c17b608ee1302ecbd03d9d3150ff297d8c1fee8 /Userland/Libraries | |
parent | 4df9ef487d14786349ee935e4d814d65921c94a3 (diff) | |
download | serenity-e391f18e9e813443ba4c6aead2041a1c01b2227a.zip |
LibVideo: Remove Starting playback state in favor of Seeking to zero
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.cpp | 38 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.h | 2 |
2 files changed, 2 insertions, 38 deletions
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 294dfff639..8482b7acd3 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -74,7 +74,7 @@ PlaybackManager::PlaybackManager(NonnullOwnPtr<Demuxer>& demuxer, Track video_tr , m_selected_video_track(video_track) , m_decoder(move(decoder)) , m_frame_queue(make<VideoFrameQueue>()) - , m_playback_handler(make<StartingStateHandler>(*this, false)) + , m_playback_handler(make<SeekingStateHandler>(*this, false, Time::zero(), SeekMode::Fast)) { if (playback_timer_creator) { m_present_timer = playback_timer_creator(0, [&] { timer_callback(); }).release_value_but_fixme_should_propagate_errors(); @@ -360,40 +360,6 @@ protected: bool m_playing { false }; }; -class PlaybackManager::StartingStateHandler : public PlaybackManager::ResumingStateHandler { - using PlaybackManager::ResumingStateHandler::ResumingStateHandler; - - ErrorOr<void> on_enter() override - { - return on_timer_callback(); - } - - StringView name() override { return "Starting"sv; } - - PlaybackState get_state() const override { return PlaybackState::Starting; } - - ErrorOr<void> on_timer_callback() override - { - // Once we're threaded, instead of checking for the count here we can just mutex - // in the queue until we display the first and then again for the second to store it. - if (manager().m_frame_queue->size() < 3) { - manager().m_decode_timer->start(0); - manager().start_timer(0); - return {}; - } - - auto frame_to_display = manager().m_frame_queue->dequeue(); - manager().m_last_present_in_media_time = frame_to_display.timestamp(); - if (manager().dispatch_frame_queue_item(move(frame_to_display))) - return {}; - - manager().m_next_frame.emplace(manager().m_frame_queue->dequeue()); - manager().m_decode_timer->start(0); - dbgln_if(PLAYBACK_MANAGER_DEBUG, "Displayed frame at {}ms, emplaced second frame at {}ms, finishing start now", manager().m_last_present_in_media_time.to_milliseconds(), manager().m_next_frame->timestamp().to_milliseconds()); - return assume_next_state(); - } -}; - class PlaybackManager::PlayingStateHandler : public PlaybackManager::PlaybackStateHandler { public: PlayingStateHandler(PlaybackManager& manager) @@ -684,7 +650,7 @@ private: auto start_timestamp = manager().seek_demuxer_to_most_recent_keyframe(Time::zero()); VERIFY(start_timestamp.has_value()); manager().m_last_present_in_media_time = start_timestamp.release_value(); - return replace_handler_and_delete_this<StartingStateHandler>(true); + return replace_handler_and_delete_this<SeekingStateHandler>(true, Time::zero(), SeekMode::Fast); } bool is_playing() const override { return false; }; PlaybackState get_state() const override { return PlaybackState::Stopped; } diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h index 1a2591d4b7..6445f72236 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.h +++ b/Userland/Libraries/LibVideo/PlaybackManager.h @@ -92,7 +92,6 @@ public: }; enum class PlaybackState { - Starting, Playing, Paused, Buffering, @@ -146,7 +145,6 @@ private: class PlaybackStateHandler; // Abstract class to allow resuming play/pause after the state is completed. class ResumingStateHandler; - class StartingStateHandler; class PlayingStateHandler; class PausedStateHandler; class BufferingStateHandler; |