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

Unified Diff: media/filters/audio_renderer_impl_unittest.cc

Issue 534073002: Switch to using media::TimeSource inside media::RendererImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
Index: media/filters/audio_renderer_impl_unittest.cc
diff --git a/media/filters/audio_renderer_impl_unittest.cc b/media/filters/audio_renderer_impl_unittest.cc
index fc6c781d3722ea40cb40c348a3a3d19e28c80f90..93204539baf6dee14cbe528bb187c0c22b8a863c 100644
--- a/media/filters/audio_renderer_impl_unittest.cc
+++ b/media/filters/audio_renderer_impl_unittest.cc
@@ -61,8 +61,6 @@ class AudioRendererImplTest : public ::testing::Test {
: hardware_config_(AudioParameters(), AudioParameters()),
demuxer_stream_(DemuxerStream::AUDIO),
decoder_(new MockAudioDecoder()),
- last_time_update_(kNoTimestamp()),
- last_max_time_(kNoTimestamp()),
ended_(false) {
AudioDecoderConfig audio_config(kCodec,
kSampleFormat,
@@ -115,20 +113,12 @@ class AudioRendererImplTest : public ::testing::Test {
MOCK_METHOD1(OnBufferingStateChange, void(BufferingState));
MOCK_METHOD1(OnError, void(PipelineStatus));
- void OnAudioTimeCallback(TimeDelta current_time, TimeDelta max_time) {
- CHECK(current_time <= max_time);
- last_time_update_ = current_time;
- last_max_time_ = max_time;
- }
-
void InitializeRenderer(const PipelineStatusCB& pipeline_status_cb) {
renderer_->Initialize(
&demuxer_stream_,
pipeline_status_cb,
base::Bind(&AudioRendererImplTest::OnStatistics,
base::Unretained(this)),
- base::Bind(&AudioRendererImplTest::OnAudioTimeCallback,
- base::Unretained(this)),
base::Bind(&AudioRendererImplTest::OnBufferingStateChange,
base::Unretained(this)),
base::Bind(&AudioRendererImplTest::OnEnded,
@@ -332,12 +322,10 @@ class AudioRendererImplTest : public ::testing::Test {
return renderer_->splicer_->HasNextBuffer();
}
- base::TimeDelta last_time_update() const {
- return last_time_update_;
+ base::TimeDelta CurrentMediaTime() {
+ return renderer_->CurrentMediaTime();
}
- base::TimeDelta last_max_time() const { return last_max_time_; }
-
bool ended() const { return ended_; }
// Fixture members.
@@ -407,8 +395,6 @@ class AudioRendererImplTest : public ::testing::Test {
base::Closure wait_for_pending_decode_cb_;
PipelineStatusCB init_decoder_cb_;
- base::TimeDelta last_time_update_;
- base::TimeDelta last_max_time_;
bool ended_;
DISALLOW_COPY_AND_ASSIGN(AudioRendererImplTest);
@@ -632,34 +618,27 @@ TEST_F(AudioRendererImplTest, TimeUpdatesOnFirstBuffer) {
StartTicking();
AudioTimestampHelper timestamp_helper(kOutputSamplesPerSecond);
- EXPECT_EQ(kNoTimestamp(), last_time_update());
- EXPECT_EQ(kNoTimestamp(), last_max_time());
+ timestamp_helper.SetBaseTimestamp(base::TimeDelta());
- // Preroll() should be buffered some data, consume half of it now.
+ // Time should be the starting timestamp as nothing's been consumed yet.
+ EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
+
+ // Consume some audio data.
OutputFrames frames_to_consume(frames_buffered().value / 2);
EXPECT_TRUE(ConsumeBufferedData(frames_to_consume));
WaitForPendingRead();
- base::RunLoop().RunUntilIdle();
- // ConsumeBufferedData() uses an audio delay of zero, so ensure we received
- // a time update that's equal to |kFramesToConsume| from above.
- timestamp_helper.SetBaseTimestamp(base::TimeDelta());
- timestamp_helper.AddFrames(frames_to_consume.value);
- EXPECT_EQ(base::TimeDelta(), last_time_update());
- EXPECT_EQ(timestamp_helper.GetTimestamp(), last_max_time());
+ // Time shouldn't change just yet because we've only sent the initial audio
+ // data to the hardware.
+ EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
- // The next time update should match the remaining frames_buffered(), but only
- // after running the message loop.
+ // Consume some more audio data.
frames_to_consume = frames_buffered();
EXPECT_TRUE(ConsumeBufferedData(frames_to_consume));
- EXPECT_EQ(base::TimeDelta(), last_time_update());
- EXPECT_EQ(timestamp_helper.GetTimestamp(), last_max_time());
- // Now the times should be updated.
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(timestamp_helper.GetTimestamp(), last_time_update());
+ // Now time should change now that the audio hardware has called back.
timestamp_helper.AddFrames(frames_to_consume.value);
- EXPECT_EQ(timestamp_helper.GetTimestamp(), last_max_time());
+ EXPECT_EQ(timestamp_helper.GetTimestamp(), CurrentMediaTime());
}
TEST_F(AudioRendererImplTest, ImmediateEndOfStream) {

Powered by Google App Engine
This is Rietveld 408576698