Commit e58f455e authored by Chris Cunningham's avatar Chris Cunningham Committed by Commit Bot

Media latencyHint: Fix crash if >0 set before init

latencyHint should be settable at any point, especially early.

This change removes the assumption that VRI algorithm_ is set prior to
latencyHint.

Bug: 1114748, 1100555
Change-Id: I69a0916674b1575547faab4fda371eb81bbea7ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2370653Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Auto-Submit: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801179}
parent faeb7654
......@@ -490,13 +490,17 @@ void VideoRendererImpl::SetLatencyHint(
<< "Video latency hint set:" << *latency_hint << ". "
<< "Effective buffering latency: 1 frame";
} else {
// Non-zero latency hints are set here. This method will also be called
// for each frame in case |average_frame_druation| changes, facilitating
// re-computation of how many frames we should buffer to achieve the target
// latency. |is_latency_hint_media_logged_| ensures that we only MEDIA_LOG
// on the first application of this hint.
// Non-zero latency hints are set here. Update buffering caps immediately if
// we already have an algorithm_. Otherwise, the update will be applied as
// frames arrive and duration becomes known. The caps will be recalculated
// for each frame in case |average_frame_druation| changes.
// |is_latency_hint_media_logged_| ensures that we only MEDIA_LOG on the
// first application of this hint.
is_latency_hint_media_logged_ = false;
UpdateLatencyHintBufferingCaps_Locked(algorithm_->average_frame_duration());
if (algorithm_) {
UpdateLatencyHintBufferingCaps_Locked(
algorithm_->average_frame_duration());
}
}
}
......
......@@ -1497,8 +1497,6 @@ TEST_F(VideoRendererLatencyHintTest, HaveEnough_LowLatencyHint) {
// Test late HaveEnough transition when high latency hint is set.
TEST_F(VideoRendererLatencyHintTest, HaveEnough_HighLatencyHint) {
Initialize();
// We must provide a |buffer_duration_| for the latencyHint to take effect
// immediately. The VideoRendererAlgorithm will eventually provide a PTS-delta
// duration, but not until after we've started rendering.
......@@ -1507,6 +1505,12 @@ TEST_F(VideoRendererLatencyHintTest, HaveEnough_HighLatencyHint) {
// Set latencyHint to a large value.
renderer_->SetLatencyHint(base::TimeDelta::FromMilliseconds(400));
// NOTE: other tests will SetLatencyHint after Initialize(). Either way should
// work. Initializing later is especially interesting for "high" hints because
// the renderer will try to set buffering caps based on stream state that
// isn't yet available.
Initialize();
// Initial frames should trigger various callbacks.
EXPECT_CALL(mock_cb_, FrameReceived(HasTimestampMatcher(0)));
EXPECT_CALL(mock_cb_, OnVideoNaturalSizeChange(_)).Times(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment