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

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

Issue 2452183003: Revert of Make more media APIs aware of |delay| and |delay_timestamp| (Closed)
Patch Set: Created 4 years, 1 month 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( 166 int frames = mixer_callback_->Render(audio_bus_.get(), 0, 0);
167 base::TimeDelta(), base::TimeTicks::Now(), 0, audio_bus_.get());
168 if (frames != audio_bus_->frames()) 167 if (frames != audio_bus_->frames())
169 return false; 168 return false;
170 169
171 // Render expected audio data (without scaling). 170 // Render expected audio data (without scaling).
172 expected_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0, 171 expected_callback_->Render(expected_audio_bus_.get(), 0, 0);
173 expected_audio_bus_.get());
174 172
175 if (half_fill_) { 173 if (half_fill_) {
176 // In this case, just verify that every frame was initialized, this will 174 // In this case, just verify that every frame was initialized, this will
177 // only fail under tooling such as valgrind. 175 // only fail under tooling such as valgrind.
178 return ValidateAudioData( 176 return ValidateAudioData(
179 0, frames, 0, std::numeric_limits<double>::max()); 177 0, frames, 0, std::numeric_limits<double>::max());
180 } else { 178 } else {
181 return ValidateAudioData(0, frames, scale); 179 return ValidateAudioData(0, frames, scale);
182 } 180 }
183 } 181 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 base::WaitableEvent::ResetPolicy::MANUAL, 482 base::WaitableEvent::ResetPolicy::MANUAL,
485 base::WaitableEvent::InitialState::NOT_SIGNALED); 483 base::WaitableEvent::InitialState::NOT_SIGNALED);
486 EXPECT_CALL(*sink_.get(), Pause()).Times(2) 484 EXPECT_CALL(*sink_.get(), Pause()).Times(2)
487 .WillRepeatedly(SignalEvent(&pause_event)); 485 .WillRepeatedly(SignalEvent(&pause_event));
488 InitializeInputs(1); 486 InitializeInputs(1);
489 487
490 // Ensure never playing the input results in a sink pause. 488 // Ensure never playing the input results in a sink pause.
491 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100); 489 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100);
492 base::TimeTicks start_time = base::TimeTicks::Now(); 490 base::TimeTicks start_time = base::TimeTicks::Now();
493 while (!pause_event.IsSignaled()) { 491 while (!pause_event.IsSignaled()) {
494 mixer_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0, 492 mixer_callback_->Render(audio_bus_.get(), 0, 0);
495 audio_bus_.get());
496 base::PlatformThread::Sleep(kSleepTime); 493 base::PlatformThread::Sleep(kSleepTime);
497 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); 494 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
498 } 495 }
499 pause_event.Reset(); 496 pause_event.Reset();
500 497
501 // Playing the input for the first time should cause a sink play. 498 // Playing the input for the first time should cause a sink play.
502 mixer_inputs_[0]->Start(); 499 mixer_inputs_[0]->Start();
503 EXPECT_CALL(*sink_.get(), Play()); 500 EXPECT_CALL(*sink_.get(), Play());
504 mixer_inputs_[0]->Play(); 501 mixer_inputs_[0]->Play();
505 mixer_inputs_[0]->Pause(); 502 mixer_inputs_[0]->Pause();
506 503
507 // Ensure once the input is paused the sink eventually pauses. 504 // Ensure once the input is paused the sink eventually pauses.
508 start_time = base::TimeTicks::Now(); 505 start_time = base::TimeTicks::Now();
509 while (!pause_event.IsSignaled()) { 506 while (!pause_event.IsSignaled()) {
510 mixer_callback_->Render(base::TimeDelta(), base::TimeTicks::Now(), 0, 507 mixer_callback_->Render(audio_bus_.get(), 0, 0);
511 audio_bus_.get());
512 base::PlatformThread::Sleep(kSleepTime); 508 base::PlatformThread::Sleep(kSleepTime);
513 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); 509 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
514 } 510 }
515 511
516 mixer_inputs_[0]->Stop(); 512 mixer_inputs_[0]->Stop();
517 } 513 }
518 514
519 INSTANTIATE_TEST_CASE_P( 515 INSTANTIATE_TEST_CASE_P(
520 AudioRendererMixerTest, 516 AudioRendererMixerTest,
521 AudioRendererMixerTest, 517 AudioRendererMixerTest,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 INSTANTIATE_TEST_CASE_P( 549 INSTANTIATE_TEST_CASE_P(
554 AudioRendererMixerBehavioralTest, 550 AudioRendererMixerBehavioralTest,
555 AudioRendererMixerBehavioralTest, 551 AudioRendererMixerBehavioralTest,
556 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( 552 testing::ValuesIn(std::vector<AudioRendererMixerTestData>(
557 1, 553 1,
558 std::tr1::make_tuple(&kTestInputLower, 554 std::tr1::make_tuple(&kTestInputLower,
559 1, 555 1,
560 kTestInputLower, 556 kTestInputLower,
561 0.00000048)))); 557 0.00000048))));
562 } // namespace media 558 } // 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