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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 // player has not yet received media crypto. 2057 // player has not yet received media crypto.
2058 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); 2058 DemuxerConfigs configs = CreateVideoDemuxerConfigs();
2059 configs.is_video_encrypted = true; 2059 configs.is_video_encrypted = true;
2060 2060
2061 player_.OnDemuxerConfigsAvailable(configs); 2061 player_.OnDemuxerConfigsAvailable(configs);
2062 CreateNextTextureAndSetVideoSurface(); 2062 CreateNextTextureAndSetVideoSurface();
2063 EXPECT_FALSE(IsPendingSurfaceChange()); 2063 EXPECT_FALSE(IsPendingSurfaceChange());
2064 EXPECT_FALSE(GetMediaDecoderJob(false)); 2064 EXPECT_FALSE(GetMediaDecoderJob(false));
2065 } 2065 }
2066 2066
2067 TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) {
2068 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2069
2070 // Test that current time is updated while decoder is starved.
2071 StartAudioDecoderJob(true);
2072 for (int i = 0; i < 3; ++i) {
2073 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
2074 WaitForAudioDecodeDone();
2075 }
2076 base::TimeDelta current_time = player_.GetCurrentTime();
2077
2078 // Trigger starvation while the decoder is decoding.
2079 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3));
2080 TriggerPlayerStarvation();
2081 WaitForAudioDecodeDone();
2082
2083 // Current time should be updated.
2084 EXPECT_LT(current_time.InMillisecondsF(),
2085 player_.GetCurrentTime().InMillisecondsF());
2086 }
2087
2088 TEST_F(MediaSourcePlayerTest, CurrentTimeKeepsIncreasingAfterConfigChange) {
2089 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2090
2091 // Test current time keep on increasing after audio config change.
2092 // Test that current time is updated while decoder is starved.
2093 StartAudioDecoderJob(true);
2094
2095 for (int i = 0; i < 4; ++i) {
2096 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
2097 WaitForAudioDecodeDone();
2098 }
2099 base::TimeDelta current_time = player_.GetCurrentTime();
2100 EXPECT_LT(0.0, current_time.InMillisecondsF());
2101
2102 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0);
2103 player_.OnDemuxerDataAvailable(data);
2104 WaitForAudioDecodeDone();
2105
2106 // Simulate arrival of new configs.
2107 player_.OnDemuxerConfigsAvailable(CreateAudioDemuxerConfigs(kCodecVorbis));
2108 for (int i = 0; i < 4; ++i) {
2109 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i));
2110 WaitForAudioDecodeDone();
2111 base::TimeDelta new_current_time = player_.GetCurrentTime();
2112 EXPECT_LE(current_time.InMillisecondsF(),
2113 new_current_time.InMillisecondsF());
2114 current_time = new_current_time;
2115 }
2116 }
2117
2067 } // namespace media 2118 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698