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

Unified Diff: media/base/android/media_source_player_unittest.cc

Issue 215783002: Fix an issue that audio and video may run out of sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing acolwell's comments Created 6 years, 8 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/base/android/media_source_player.cc ('k') | media/base/android/video_decoder_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_source_player_unittest.cc
diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc
index 9c6a0627d1184dce97f620e96a59465a5cb0f697..73243365f56324312def1e30786afecdc0800626 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -2067,4 +2067,55 @@ TEST_F(MediaSourcePlayerTest, SurfaceChangeClearedEvenIfMediaCryptoAbsent) {
EXPECT_FALSE(GetMediaDecoderJob(false));
}
+TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) {
+ SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
+
+ // Test that current time is updated while decoder is starved.
+ StartAudioDecoderJob(true);
+ for (int i = 0; i < 3; ++i) {
+ player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
+ WaitForAudioDecodeDone();
+ }
+ base::TimeDelta current_time = player_.GetCurrentTime();
+
+ // Trigger starvation while the decoder is decoding.
+ player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3));
+ TriggerPlayerStarvation();
+ WaitForAudioDecodeDone();
+
+ // Current time should be updated.
+ EXPECT_LT(current_time.InMillisecondsF(),
+ player_.GetCurrentTime().InMillisecondsF());
+}
+
+TEST_F(MediaSourcePlayerTest, CurrentTimeKeepsIncreasingAfterConfigChange) {
+ SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
+
+ // Test current time keep on increasing after audio config change.
+ // Test that current time is updated while decoder is starved.
+ StartAudioDecoderJob(true);
+
+ for (int i = 0; i < 4; ++i) {
+ player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
+ WaitForAudioDecodeDone();
+ }
+ base::TimeDelta current_time = player_.GetCurrentTime();
+ EXPECT_LT(0.0, current_time.InMillisecondsF());
+
+ DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0);
+ player_.OnDemuxerDataAvailable(data);
+ WaitForAudioDecodeDone();
+
+ // Simulate arrival of new configs.
+ player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
+ for (int i = 0; i < 4; ++i) {
+ player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
+ WaitForAudioDecodeDone();
+ base::TimeDelta new_current_time = player_.GetCurrentTime();
+ EXPECT_LE(current_time.InMillisecondsF(),
+ new_current_time.InMillisecondsF());
+ current_time = new_current_time;
+ }
+}
+
} // namespace media
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | media/base/android/video_decoder_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698