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

Side by Side Diff: media/base/audio_renderer_mixer_unittest.cc

Issue 2517503003: Reland: Make more media APIs aware of |delay| and |delay_timestamp| (Closed)
Patch Set: Comments from chcunningham@ and Dale Created 4 years 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
« no previous file with comments | « media/base/audio_renderer_mixer_input.cc ('k') | media/base/audio_renderer_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "media/base/audio_renderer_mixer.h" 8 #include "media/base/audio_renderer_mixer.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (half_fill_) { 156 if (half_fill_) {
157 for (size_t i = 0; i < fake_callbacks_.size(); ++i) 157 for (size_t i = 0; i < fake_callbacks_.size(); ++i)
158 fake_callbacks_[i]->set_half_fill(true); 158 fake_callbacks_[i]->set_half_fill(true);
159 expected_callback_->set_half_fill(true); 159 expected_callback_->set_half_fill(true);
160 // Initialize the AudioBus completely or we'll run into Valgrind problems 160 // Initialize the AudioBus completely or we'll run into Valgrind problems
161 // during the verification step below. 161 // during the verification step below.
162 expected_audio_bus_->Zero(); 162 expected_audio_bus_->Zero();
163 } 163 }
164 164
165 // Render actual audio data. 165 // Render actual audio data.
166 int frames = mixer_callback_->Render(audio_bus_.get(), 0, 0); 166 int frames = mixer_callback_->Render(
167 base::TimeDelta(), base::TimeTicks::Now(), 0, audio_bus_.get());
167 if (frames != audio_bus_->frames()) 168 if (frames != audio_bus_->frames())
168 return false; 169 return false;
169 170
170 // Render expected audio data (without scaling). 171 // Render expected audio data (without scaling).
171 expected_callback_->Render(expected_audio_bus_.get(), 0, 0); 172 expected_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0,
173 expected_audio_bus_.get());
172 174
173 if (half_fill_) { 175 if (half_fill_) {
174 // In this case, just verify that every frame was initialized, this will 176 // In this case, just verify that every frame was initialized, this will
175 // only fail under tooling such as valgrind. 177 // only fail under tooling such as valgrind.
176 return ValidateAudioData( 178 return ValidateAudioData(
177 0, frames, 0, std::numeric_limits<double>::max()); 179 0, frames, 0, std::numeric_limits<double>::max());
178 } else { 180 } else {
179 return ValidateAudioData(0, frames, scale); 181 return ValidateAudioData(0, frames, scale);
180 } 182 }
181 } 183 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 base::WaitableEvent::ResetPolicy::MANUAL, 484 base::WaitableEvent::ResetPolicy::MANUAL,
483 base::WaitableEvent::InitialState::NOT_SIGNALED); 485 base::WaitableEvent::InitialState::NOT_SIGNALED);
484 EXPECT_CALL(*sink_.get(), Pause()).Times(2) 486 EXPECT_CALL(*sink_.get(), Pause()).Times(2)
485 .WillRepeatedly(SignalEvent(&pause_event)); 487 .WillRepeatedly(SignalEvent(&pause_event));
486 InitializeInputs(1); 488 InitializeInputs(1);
487 489
488 // Ensure never playing the input results in a sink pause. 490 // Ensure never playing the input results in a sink pause.
489 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100); 491 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100);
490 base::TimeTicks start_time = base::TimeTicks::Now(); 492 base::TimeTicks start_time = base::TimeTicks::Now();
491 while (!pause_event.IsSignaled()) { 493 while (!pause_event.IsSignaled()) {
492 mixer_callback_->Render(audio_bus_.get(), 0, 0); 494 mixer_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0,
495 audio_bus_.get());
493 base::PlatformThread::Sleep(kSleepTime); 496 base::PlatformThread::Sleep(kSleepTime);
494 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); 497 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
495 } 498 }
496 pause_event.Reset(); 499 pause_event.Reset();
497 500
498 // Playing the input for the first time should cause a sink play. 501 // Playing the input for the first time should cause a sink play.
499 mixer_inputs_[0]->Start(); 502 mixer_inputs_[0]->Start();
500 EXPECT_CALL(*sink_.get(), Play()); 503 EXPECT_CALL(*sink_.get(), Play());
501 mixer_inputs_[0]->Play(); 504 mixer_inputs_[0]->Play();
502 mixer_inputs_[0]->Pause(); 505 mixer_inputs_[0]->Pause();
503 506
504 // Ensure once the input is paused the sink eventually pauses. 507 // Ensure once the input is paused the sink eventually pauses.
505 start_time = base::TimeTicks::Now(); 508 start_time = base::TimeTicks::Now();
506 while (!pause_event.IsSignaled()) { 509 while (!pause_event.IsSignaled()) {
507 mixer_callback_->Render(audio_bus_.get(), 0, 0); 510 mixer_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0,
511 audio_bus_.get());
508 base::PlatformThread::Sleep(kSleepTime); 512 base::PlatformThread::Sleep(kSleepTime);
509 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); 513 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
510 } 514 }
511 515
512 mixer_inputs_[0]->Stop(); 516 mixer_inputs_[0]->Stop();
513 } 517 }
514 518
515 INSTANTIATE_TEST_CASE_P( 519 INSTANTIATE_TEST_CASE_P(
516 AudioRendererMixerTest, 520 AudioRendererMixerTest,
517 AudioRendererMixerTest, 521 AudioRendererMixerTest,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 INSTANTIATE_TEST_CASE_P( 553 INSTANTIATE_TEST_CASE_P(
550 AudioRendererMixerBehavioralTest, 554 AudioRendererMixerBehavioralTest,
551 AudioRendererMixerBehavioralTest, 555 AudioRendererMixerBehavioralTest,
552 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( 556 testing::ValuesIn(std::vector<AudioRendererMixerTestData>(
553 1, 557 1,
554 std::tr1::make_tuple(&kTestInputLower, 558 std::tr1::make_tuple(&kTestInputLower,
555 1, 559 1,
556 kTestInputLower, 560 kTestInputLower,
557 0.00000048)))); 561 0.00000048))));
558 } // namespace media 562 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_input.cc ('k') | media/base/audio_renderer_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698