UpdateCurrentDelay should update delay with rounding errors
Some of the timestamps input into UpdateCurrentDelay are not truncated to milliseconds and thus a small negative delay can result. This means the delay will not update when it should have. Bug: webrtc:14168 Change-Id: I5293339b6a39201c680854e9596b717025ee8dc1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266370 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Evan Shrubsole <eshr@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37657}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
bf607e2564
commit
496ad52cb2
@ -157,7 +157,9 @@ void VCMTiming::UpdateCurrentDelay(Timestamp render_time,
|
|||||||
TimeDelta target_delay = TargetDelayInternal();
|
TimeDelta target_delay = TargetDelayInternal();
|
||||||
TimeDelta delayed =
|
TimeDelta delayed =
|
||||||
(actual_decode_time - render_time) + RequiredDecodeTime() + render_delay_;
|
(actual_decode_time - render_time) + RequiredDecodeTime() + render_delay_;
|
||||||
if (delayed < TimeDelta::Zero()) {
|
|
||||||
|
// Only consider `delayed` as negative by more than a few microseconds.
|
||||||
|
if (delayed.ms() < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (current_delay_ + delayed <= target_delay) {
|
if (current_delay_ + delayed <= target_delay) {
|
||||||
|
@ -316,4 +316,24 @@ TEST(ReceiverTimingTest, MaxWaitingTimeReturnsZeroIfTooManyFramesQueuedIsTrue) {
|
|||||||
TimeDelta::Zero());
|
TimeDelta::Zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ReceiverTimingTest, UpdateCurrentDelayCapsWhenOffByMicroseconds) {
|
||||||
|
test::ScopedKeyValueConfig field_trials;
|
||||||
|
SimulatedClock clock(0);
|
||||||
|
VCMTiming timing(&clock, field_trials);
|
||||||
|
timing.Reset();
|
||||||
|
|
||||||
|
// Set larger initial current delay.
|
||||||
|
timing.set_min_playout_delay(TimeDelta::Millis(200));
|
||||||
|
timing.UpdateCurrentDelay(Timestamp::Millis(900), Timestamp::Millis(1000));
|
||||||
|
|
||||||
|
// Add a few microseconds to ensure that the delta of decode time is 0 after
|
||||||
|
// rounding, and should reset to the target delay.
|
||||||
|
timing.set_min_playout_delay(TimeDelta::Millis(50));
|
||||||
|
Timestamp decode_time = Timestamp::Millis(1337);
|
||||||
|
Timestamp render_time =
|
||||||
|
decode_time + TimeDelta::Millis(10) + TimeDelta::Micros(37);
|
||||||
|
timing.UpdateCurrentDelay(render_time, decode_time);
|
||||||
|
EXPECT_EQ(timing.GetTimings().current_delay, timing.TargetVideoDelay());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Reference in New Issue
Block a user