LibMedia: Route current time through the playback state handler

This has no effect on the user experience, and likely also produces the
same timestamps during a seek as before. However, it is needed in order
to ensure that the future Ended state is always at the duration.
This commit is contained in:
Zaggy1024 2026-06-09 17:25:24 -05:00 committed by Gregory Bertilson
parent e2e2635752
commit d2c993dec0
5 changed files with 16 additions and 1 deletions

View file

@ -243,6 +243,12 @@ void PlaybackManager::set_up_producers()
}
}
AK::Duration PlaybackManager::current_time() const
{
auto time = m_handler->current_time();
return min(time, duration());
}
void PlaybackManager::on_audio_sink_state_changed(PipelineStatus status)
{
m_audio_buffering = status == PipelineStatus::Blocked;

View file

@ -55,7 +55,7 @@ public:
AK::Duration duration() const { return m_duration; }
void set_duration(AK::Duration duration) { m_duration = duration; }
AK::Duration current_time() const { return min(m_time_provider->current_time(), duration()); }
AK::Duration current_time() const;
Optional<AK::UnixDateTime> start_time_realtime() const { return m_start_time_realtime; }

View file

@ -11,6 +11,11 @@
namespace Media {
AK::Duration PlaybackStateHandler::current_time() const
{
return manager().m_time_provider->current_time();
}
void PlaybackStateHandler::seek(AK::Duration timestamp, SeekMode mode)
{
manager().replace_state_handler<SeekingStateHandler>(manager().is_playing(), timestamp, mode);

View file

@ -26,6 +26,8 @@ public:
virtual void on_enter() = 0;
virtual void on_exit() = 0;
virtual AK::Duration current_time() const;
virtual void start() { }
virtual void play() = 0;
virtual void pause() = 0;

View file

@ -42,6 +42,8 @@ public:
VERIFY(!m_audio_seek_pending);
}
virtual AK::Duration current_time() const override { return m_chosen_timestamp; }
virtual void seek(AK::Duration timestamp, SeekMode mode) override
{
m_target_timestamp = timestamp;