OLD | NEW |
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 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (half_fill_) { | 149 if (half_fill_) { |
150 for (size_t i = 0; i < fake_callbacks_.size(); ++i) | 150 for (size_t i = 0; i < fake_callbacks_.size(); ++i) |
151 fake_callbacks_[i]->set_half_fill(true); | 151 fake_callbacks_[i]->set_half_fill(true); |
152 expected_callback_->set_half_fill(true); | 152 expected_callback_->set_half_fill(true); |
153 // Initialize the AudioBus completely or we'll run into Valgrind problems | 153 // Initialize the AudioBus completely or we'll run into Valgrind problems |
154 // during the verification step below. | 154 // during the verification step below. |
155 expected_audio_bus_->Zero(); | 155 expected_audio_bus_->Zero(); |
156 } | 156 } |
157 | 157 |
158 // Render actual audio data. | 158 // Render actual audio data. |
159 int frames = mixer_callback_->Render(audio_bus_.get(), 0); | 159 int frames = mixer_callback_->Render(audio_bus_.get(), 0, 0); |
160 if (frames != audio_bus_->frames()) | 160 if (frames != audio_bus_->frames()) |
161 return false; | 161 return false; |
162 | 162 |
163 // Render expected audio data (without scaling). | 163 // Render expected audio data (without scaling). |
164 expected_callback_->Render(expected_audio_bus_.get(), 0); | 164 expected_callback_->Render(expected_audio_bus_.get(), 0, 0); |
165 | 165 |
166 if (half_fill_) { | 166 if (half_fill_) { |
167 // In this case, just verify that every frame was initialized, this will | 167 // In this case, just verify that every frame was initialized, this will |
168 // only fail under tooling such as valgrind. | 168 // only fail under tooling such as valgrind. |
169 return ValidateAudioData( | 169 return ValidateAudioData( |
170 0, frames, 0, std::numeric_limits<double>::max()); | 170 0, frames, 0, std::numeric_limits<double>::max()); |
171 } else { | 171 } else { |
172 return ValidateAudioData(0, frames, scale); | 172 return ValidateAudioData(0, frames, scale); |
173 } | 173 } |
174 } | 174 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 base::WaitableEvent pause_event(true, false); | 480 base::WaitableEvent pause_event(true, false); |
481 EXPECT_CALL(*sink_.get(), Pause()).Times(2) | 481 EXPECT_CALL(*sink_.get(), Pause()).Times(2) |
482 .WillRepeatedly(SignalEvent(&pause_event)); | 482 .WillRepeatedly(SignalEvent(&pause_event)); |
483 InitializeInputs(1); | 483 InitializeInputs(1); |
484 | 484 |
485 // Ensure never playing the input results in a sink pause. | 485 // Ensure never playing the input results in a sink pause. |
486 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100); | 486 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100); |
487 base::TimeTicks start_time = base::TimeTicks::Now(); | 487 base::TimeTicks start_time = base::TimeTicks::Now(); |
488 while (!pause_event.IsSignaled()) { | 488 while (!pause_event.IsSignaled()) { |
489 mixer_callback_->Render(audio_bus_.get(), 0); | 489 mixer_callback_->Render(audio_bus_.get(), 0, 0); |
490 base::PlatformThread::Sleep(kSleepTime); | 490 base::PlatformThread::Sleep(kSleepTime); |
491 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); | 491 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); |
492 } | 492 } |
493 pause_event.Reset(); | 493 pause_event.Reset(); |
494 | 494 |
495 // Playing the input for the first time should cause a sink play. | 495 // Playing the input for the first time should cause a sink play. |
496 mixer_inputs_[0]->Start(); | 496 mixer_inputs_[0]->Start(); |
497 EXPECT_CALL(*sink_.get(), Play()); | 497 EXPECT_CALL(*sink_.get(), Play()); |
498 mixer_inputs_[0]->Play(); | 498 mixer_inputs_[0]->Play(); |
499 mixer_inputs_[0]->Pause(); | 499 mixer_inputs_[0]->Pause(); |
500 | 500 |
501 // Ensure once the input is paused the sink eventually pauses. | 501 // Ensure once the input is paused the sink eventually pauses. |
502 start_time = base::TimeTicks::Now(); | 502 start_time = base::TimeTicks::Now(); |
503 while (!pause_event.IsSignaled()) { | 503 while (!pause_event.IsSignaled()) { |
504 mixer_callback_->Render(audio_bus_.get(), 0); | 504 mixer_callback_->Render(audio_bus_.get(), 0, 0); |
505 base::PlatformThread::Sleep(kSleepTime); | 505 base::PlatformThread::Sleep(kSleepTime); |
506 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); | 506 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout); |
507 } | 507 } |
508 | 508 |
509 mixer_inputs_[0]->Stop(); | 509 mixer_inputs_[0]->Stop(); |
510 } | 510 } |
511 | 511 |
512 INSTANTIATE_TEST_CASE_P( | 512 INSTANTIATE_TEST_CASE_P( |
513 AudioRendererMixerTest, | 513 AudioRendererMixerTest, |
514 AudioRendererMixerTest, | 514 AudioRendererMixerTest, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 INSTANTIATE_TEST_CASE_P( | 546 INSTANTIATE_TEST_CASE_P( |
547 AudioRendererMixerBehavioralTest, | 547 AudioRendererMixerBehavioralTest, |
548 AudioRendererMixerBehavioralTest, | 548 AudioRendererMixerBehavioralTest, |
549 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( | 549 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( |
550 1, | 550 1, |
551 std::tr1::make_tuple(&kTestInputLower, | 551 std::tr1::make_tuple(&kTestInputLower, |
552 1, | 552 1, |
553 kTestInputLower, | 553 kTestInputLower, |
554 0.00000048)))); | 554 0.00000048)))); |
555 } // namespace media | 555 } // namespace media |
OLD | NEW |