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