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 | 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 mixer_.reset( | 81 mixer_.reset( |
82 new AudioRendererMixer(output_parameters_, sink_, base::Bind(&LogUma))); | 82 new AudioRendererMixer(output_parameters_, sink_, base::Bind(&LogUma))); |
83 mixer_callback_ = sink_->callback(); | 83 mixer_callback_ = sink_->callback(); |
84 | 84 |
85 audio_bus_ = AudioBus::Create(output_parameters_); | 85 audio_bus_ = AudioBus::Create(output_parameters_); |
86 expected_audio_bus_ = AudioBus::Create(output_parameters_); | 86 expected_audio_bus_ = AudioBus::Create(output_parameters_); |
87 | 87 |
88 // Allocate one callback for generating expected results. | 88 // Allocate one callback for generating expected results. |
89 double step = kSineCycles / static_cast<double>( | 89 double step = kSineCycles / static_cast<double>( |
90 output_parameters_.frames_per_buffer()); | 90 output_parameters_.frames_per_buffer()); |
91 expected_callback_.reset(new FakeAudioRenderCallback(step)); | 91 expected_callback_.reset( |
| 92 new FakeAudioRenderCallback(step, output_parameters_.sample_rate())); |
92 } | 93 } |
93 | 94 |
94 AudioRendererMixer* GetMixer(int owner_id, | 95 AudioRendererMixer* GetMixer(int owner_id, |
95 const AudioParameters& params, | 96 const AudioParameters& params, |
96 AudioLatency::LatencyType latency, | 97 AudioLatency::LatencyType latency, |
97 const std::string& device_id, | 98 const std::string& device_id, |
98 const url::Origin& security_origin, | 99 const url::Origin& security_origin, |
99 OutputDeviceStatus* device_status) final { | 100 OutputDeviceStatus* device_status) final { |
100 return mixer_.get(); | 101 return mixer_.get(); |
101 }; | 102 }; |
(...skipping 12 matching lines...) Expand all Loading... |
114 // Setup FakeAudioRenderCallback step to compensate for resampling. | 115 // Setup FakeAudioRenderCallback step to compensate for resampling. |
115 double scale_factor = | 116 double scale_factor = |
116 input_parameters_[i].sample_rate() / | 117 input_parameters_[i].sample_rate() / |
117 static_cast<double>(output_parameters_.sample_rate()); | 118 static_cast<double>(output_parameters_.sample_rate()); |
118 double step = | 119 double step = |
119 kSineCycles / | 120 kSineCycles / |
120 (scale_factor * | 121 (scale_factor * |
121 static_cast<double>(output_parameters_.frames_per_buffer())); | 122 static_cast<double>(output_parameters_.frames_per_buffer())); |
122 | 123 |
123 for (int j = 0; j < inputs_per_sample_rate; ++j, ++input) { | 124 for (int j = 0; j < inputs_per_sample_rate; ++j, ++input) { |
124 fake_callbacks_.push_back(new FakeAudioRenderCallback(step)); | 125 fake_callbacks_.push_back(new FakeAudioRenderCallback( |
| 126 step, output_parameters_.sample_rate())); |
125 mixer_inputs_.push_back(CreateMixerInput()); | 127 mixer_inputs_.push_back(CreateMixerInput()); |
126 mixer_inputs_[input]->Initialize(input_parameters_[i], | 128 mixer_inputs_[input]->Initialize(input_parameters_[i], |
127 fake_callbacks_[input]); | 129 fake_callbacks_[input]); |
128 mixer_inputs_[input]->SetVolume(1.0f); | 130 mixer_inputs_[input]->SetVolume(1.0f); |
129 } | 131 } |
130 } | 132 } |
131 } | 133 } |
132 | 134 |
133 bool ValidateAudioData(int index, int frames, float scale, double epsilon) { | 135 bool ValidateAudioData(int index, int frames, float scale, double epsilon) { |
134 for (int i = 0; i < audio_bus_->channels(); ++i) { | 136 for (int i = 0; i < audio_bus_->channels(); ++i) { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 INSTANTIATE_TEST_CASE_P( | 555 INSTANTIATE_TEST_CASE_P( |
554 AudioRendererMixerBehavioralTest, | 556 AudioRendererMixerBehavioralTest, |
555 AudioRendererMixerBehavioralTest, | 557 AudioRendererMixerBehavioralTest, |
556 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( | 558 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( |
557 1, | 559 1, |
558 std::tr1::make_tuple(&kTestInputLower, | 560 std::tr1::make_tuple(&kTestInputLower, |
559 1, | 561 1, |
560 kTestInputLower, | 562 kTestInputLower, |
561 0.00000048)))); | 563 0.00000048)))); |
562 } // namespace media | 564 } // namespace media |
OLD | NEW |