OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "media/audio/audio_parameters.h" | 7 #include "media/audio/audio_parameters.h" |
8 #include "media/base/fake_audio_render_callback.h" | 8 #include "media/base/fake_audio_render_callback.h" |
9 #include "media/base/mock_audio_renderer_sink.h" | 9 #include "media/base/mock_audio_renderer_sink.h" |
10 #include "media/blink/webaudiosourceprovider_impl.h" | 10 #include "media/blink/webaudiosourceprovider_impl.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ASSERT_EQ(fake_callback_.last_audio_delay_milliseconds(), -1); | 190 ASSERT_EQ(fake_callback_.last_audio_delay_milliseconds(), -1); |
191 | 191 |
192 wasp_impl_->Play(); | 192 wasp_impl_->Play(); |
193 | 193 |
194 // Now we should get real audio data. | 194 // Now we should get real audio data. |
195 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); | 195 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); |
196 ASSERT_FALSE(CompareBusses(bus1.get(), bus2.get())); | 196 ASSERT_FALSE(CompareBusses(bus1.get(), bus2.get())); |
197 | 197 |
198 // Ensure volume adjustment is working. | 198 // Ensure volume adjustment is working. |
199 fake_callback_.reset(); | 199 fake_callback_.reset(); |
200 fake_callback_.Render(bus2.get(), 0); | 200 fake_callback_.Render(bus2.get(), 0, 0); |
201 bus2->Scale(kTestVolume); | 201 bus2->Scale(kTestVolume); |
202 | 202 |
203 fake_callback_.reset(); | 203 fake_callback_.reset(); |
204 wasp_impl_->SetVolume(kTestVolume); | 204 wasp_impl_->SetVolume(kTestVolume); |
205 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); | 205 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); |
206 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); | 206 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); |
207 | 207 |
208 // Pause should return to silence. | 208 // Pause should return to silence. |
209 wasp_impl_->Pause(); | 209 wasp_impl_->Pause(); |
210 bus1->channel(0)[0] = 1; | 210 bus1->channel(0)[0] = 1; |
211 bus2->Zero(); | 211 bus2->Zero(); |
212 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); | 212 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); |
213 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); | 213 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); |
214 | 214 |
215 // Ensure if a renderer properly fill silence for partial Render() calls by | 215 // Ensure if a renderer properly fill silence for partial Render() calls by |
216 // configuring the fake callback to return half the data. After these calls | 216 // configuring the fake callback to return half the data. After these calls |
217 // bus1 is full of junk data, and bus2 is partially filled. | 217 // bus1 is full of junk data, and bus2 is partially filled. |
218 wasp_impl_->SetVolume(1); | 218 wasp_impl_->SetVolume(1); |
219 fake_callback_.Render(bus1.get(), 0); | 219 fake_callback_.Render(bus1.get(), 0, 0); |
220 fake_callback_.reset(); | 220 fake_callback_.reset(); |
221 fake_callback_.Render(bus2.get(), 0); | 221 fake_callback_.Render(bus2.get(), 0, 0); |
222 bus2->ZeroFramesPartial(bus2->frames() / 2, | 222 bus2->ZeroFramesPartial(bus2->frames() / 2, |
223 bus2->frames() - bus2->frames() / 2); | 223 bus2->frames() - bus2->frames() / 2); |
224 fake_callback_.reset(); | 224 fake_callback_.reset(); |
225 fake_callback_.set_half_fill(true); | 225 fake_callback_.set_half_fill(true); |
226 wasp_impl_->Play(); | 226 wasp_impl_->Play(); |
227 | 227 |
228 // Play should return real audio data again, but the last half should be zero. | 228 // Play should return real audio data again, but the last half should be zero. |
229 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); | 229 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); |
230 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); | 230 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); |
231 | 231 |
232 // Stop() should return silence. | 232 // Stop() should return silence. |
233 wasp_impl_->Stop(); | 233 wasp_impl_->Stop(); |
234 bus1->channel(0)[0] = 1; | 234 bus1->channel(0)[0] = 1; |
235 bus2->Zero(); | 235 bus2->Zero(); |
236 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); | 236 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); |
237 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); | 237 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); |
238 } | 238 } |
239 | 239 |
240 } // namespace media | 240 } // namespace media |
OLD | NEW |