Skip to content

Commit

Permalink
Cherry pick PR #2103: Remove audio write limit after video eos written (
Browse files Browse the repository at this point in the history
#2537)

Refer to the original PR: #2103

b/309651931

---------

Co-authored-by: Jason <jasonzh@google.com>
  • Loading branch information
cobalt-github-releaser-bot and jasonzhangxx committed Mar 19, 2024
1 parent bfd86ef commit 148d5d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 148d5d1

Please sign in to comment.