Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: media/filters/audio_clock_unittest.cc

Issue 1160853006: Improve audio/video sync during underflow, reduce underflow frequency. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/audio_clock.cc ('k') | media/filters/video_renderer_algorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_clock_unittest.cc
diff --git a/media/filters/audio_clock_unittest.cc b/media/filters/audio_clock_unittest.cc
index 3fe437ee24c6f42829281a47ec698bfa3e74818f..2144bb0d67037504d93ee59d04a0b85bcd936b55 100644
--- a/media/filters/audio_clock_unittest.cc
+++ b/media/filters/audio_clock_unittest.cc
@@ -330,4 +330,30 @@ TEST_F(AudioClockTest, SupportsYearsWorthOfAudioData) {
EXPECT_EQ((huge * 2).InDays(), ContiguousAudioDataBufferedInDays());
}
+TEST_F(AudioClockTest, CompensateForSuspendedWrites) {
+ // Buffer 6 seconds of delay and 1 second of audio data.
+ WroteAudio(10, 10, 60, 1.0);
+
+ // Media timestamp zero has to wait for silence to pass.
+ const int kBaseTimeMs = 6000;
+ EXPECT_EQ(kBaseTimeMs, TimeUntilPlaybackInMilliseconds(0));
+
+ // Elapsing frames less than we have buffered should do nothing.
+ const int kDelayFrames = 2;
+ for (int i = 1000; i <= kBaseTimeMs; i += 1000) {
+ clock_.CompensateForSuspendedWrites(base::TimeDelta::FromMilliseconds(i),
+ kDelayFrames);
+ EXPECT_EQ(kBaseTimeMs - (i - 1000), TimeUntilPlaybackInMilliseconds(0));
+
+ // Write silence to simulate maintaining a 7s output buffer.
+ WroteAudio(0, 10, 60, 1.0);
+ }
+
+ // Exhausting all frames should advance timestamps and prime the buffer with
+ // our delay frames value.
+ clock_.CompensateForSuspendedWrites(base::TimeDelta::FromMilliseconds(7000),
+ kDelayFrames);
+ EXPECT_EQ(kDelayFrames * 100, TimeUntilPlaybackInMilliseconds(1000));
+}
+
} // namespace media
« no previous file with comments | « media/filters/audio_clock.cc ('k') | media/filters/video_renderer_algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698