Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick PR #2103: Remove audio write limit after video eos written #2537

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cobalt/media/base/sbplayer_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cobalt/media/base/sbplayer_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SbTime> last_media_time_;
Expand Down
Loading