diff --git a/cobalt/media/base/sbplayer_pipeline.cc b/cobalt/media/base/sbplayer_pipeline.cc index 994f7b96c063..7014713ab982 100644 --- a/cobalt/media/base/sbplayer_pipeline.cc +++ b/cobalt/media/base/sbplayer_pipeline.cc @@ -391,6 +391,7 @@ void SbPlayerPipeline::Seek(TimeDelta time, const SeekCB& seek_cb) { StoreMediaTime(seek_time_); retrograde_media_time_counter_ = 0; timestamp_of_last_written_audio_ = 0; + is_video_eos_written_ = false; #if SB_HAS(PLAYER_WITH_URL) if (is_url_based_) { @@ -1055,6 +1056,9 @@ void SbPlayerPipeline::OnDemuxerStreamRead( } else { for (const auto& buffer : buffers) { playback_statistics_.OnVideoAU(buffer); + if (buffer->end_of_stream()) { + is_video_eos_written_ = true; + } } } SetReadInProgress(type, false); @@ -1096,7 +1100,8 @@ void SbPlayerPipeline::OnNeedData(DemuxerStream::Type type, // after the player has received enough audio for preroll, taking into // account that our estimate of playback time might be behind by // |kMediaTimeCheckInterval|. - if (timestamp_of_last_written_audio_ - seek_time_.ToSbTime() > + if (!is_video_eos_written_ && + timestamp_of_last_written_audio_ - seek_time_.ToSbTime() > AdjustWriteDurationForPlaybackRate(audio_write_duration_for_preroll_, playback_rate_)) { // The estimated time ahead of playback may be negative if no audio has diff --git a/cobalt/media/base/sbplayer_pipeline.h b/cobalt/media/base/sbplayer_pipeline.h index 9b793f595b22..55611fec3fca 100644 --- a/cobalt/media/base/sbplayer_pipeline.h +++ b/cobalt/media/base/sbplayer_pipeline.h @@ -337,6 +337,9 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, static const SbTime kMediaTimeCheckInterval = 0.1 * kSbTimeSecond; // Timestamp for the last written audio. SbTime timestamp_of_last_written_audio_ = 0; + // Indicates if video end of stream has been written into the underlying + // player. + bool is_video_eos_written_ = false; // Last media time reported by GetMediaTime(). base::CVal last_media_time_;