mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
LibVideo: Always present a frame when not fast-exiting seek
Previously, there was some leftover logic in `SeekingStateHandler` which would avoid presenting a frame if it didn't find a frame both before and after the target frame. However, this logic was unnecessary as the `on_enter()` function would check if it needed to present a frame and exit seeking if not. This allows seeking to succeed if the Seeking handler cannot find a frame before the one to be seeked to, which could occur if the first frame of a video is not at timestamp 0.
This commit is contained in:
parent
989f965f54
commit
b081967762
1 changed files with 10 additions and 7 deletions
|
@ -580,13 +580,14 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_seek_mode == SeekMode::Fast) {
|
if (m_seek_mode == SeekMode::Fast) {
|
||||||
m_target_timestamp = keyframe_timestamp.value_or(earliest_available_sample);
|
m_target_timestamp = keyframe_timestamp.value_or(manager().m_last_present_in_media_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyframe_timestamp.has_value()) {
|
if (keyframe_timestamp.has_value()) {
|
||||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Keyframe is nearer to the target than the current frames, clearing queue");
|
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Keyframe is nearer to the target than the current frames, clearing queue");
|
||||||
manager().m_frame_queue->clear();
|
manager().m_frame_queue->clear();
|
||||||
manager().m_next_frame.clear();
|
manager().m_next_frame.clear();
|
||||||
|
manager().m_last_present_in_media_time = keyframe_timestamp.value();
|
||||||
} else if (m_target_timestamp >= manager().m_last_present_in_media_time && manager().m_next_frame.has_value() && manager().m_next_frame.value().timestamp() > m_target_timestamp) {
|
} else if (m_target_timestamp >= manager().m_last_present_in_media_time && manager().m_next_frame.has_value() && manager().m_next_frame.value().timestamp() > m_target_timestamp) {
|
||||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Target timestamp is between the last presented frame and the next frame, exiting seek at {}ms", m_target_timestamp.to_milliseconds());
|
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Target timestamp is between the last presented frame and the next frame, exiting seek at {}ms", m_target_timestamp.to_milliseconds());
|
||||||
manager().m_last_present_in_media_time = m_target_timestamp;
|
manager().m_last_present_in_media_time = m_target_timestamp;
|
||||||
|
@ -603,15 +604,17 @@ private:
|
||||||
manager().m_decode_timer->start(0);
|
manager().m_decode_timer->start(0);
|
||||||
|
|
||||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Dequeuing frame at {}ms and comparing to seek target {}ms", item.timestamp().to_milliseconds(), m_target_timestamp.to_milliseconds());
|
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Dequeuing frame at {}ms and comparing to seek target {}ms", item.timestamp().to_milliseconds(), m_target_timestamp.to_milliseconds());
|
||||||
if (item.timestamp() > m_target_timestamp || item.timestamp() == FrameQueueItem::no_timestamp) {
|
if (manager().m_next_frame.has_value() && (item.timestamp() > m_target_timestamp || item.timestamp() == FrameQueueItem::no_timestamp)) {
|
||||||
// Fast seeking will result in an equal timestamp, so we can exit as soon as we see the next frame.
|
// If the frame we're presenting is later than the target timestamp, skip the timestamp forward to it.
|
||||||
if (manager().m_next_frame.has_value()) {
|
if (manager().m_next_frame->timestamp() > m_target_timestamp) {
|
||||||
|
manager().m_last_present_in_media_time = manager().m_next_frame->timestamp();
|
||||||
|
} else {
|
||||||
manager().m_last_present_in_media_time = m_target_timestamp;
|
manager().m_last_present_in_media_time = m_target_timestamp;
|
||||||
|
|
||||||
if (manager().dispatch_frame_queue_item(manager().m_next_frame.release_value()))
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (manager().dispatch_frame_queue_item(manager().m_next_frame.release_value()))
|
||||||
|
return {};
|
||||||
|
|
||||||
manager().m_next_frame.emplace(item);
|
manager().m_next_frame.emplace(item);
|
||||||
|
|
||||||
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Exiting seek to {} state at {}ms", m_playing ? "Playing" : "Paused", manager().m_last_present_in_media_time.to_milliseconds());
|
dbgln_if(PLAYBACK_MANAGER_DEBUG, "Exiting seek to {} state at {}ms", m_playing ? "Playing" : "Paused", manager().m_last_present_in_media_time.to_milliseconds());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue