| 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 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 5 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 // We expect 2 mixers to be created; each of them should release the sink. | 295 // We expect 2 mixers to be created; each of them should release the sink. |
| 296 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(2); | 296 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(2); |
| 297 | 297 |
| 298 media::AudioParameters params( | 298 media::AudioParameters params( |
| 299 AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, | 299 AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, kSampleRate, |
| 300 kBitsPerChannel, kBufferSize); | 300 kBitsPerChannel, kBufferSize); |
| 301 | 301 |
| 302 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet. | 302 // Create two mixer inputs and ensure this doesn't instantiate any mixers yet. |
| 303 EXPECT_EQ(0, mixer_count()); | 303 EXPECT_EQ(0, mixer_count()); |
| 304 media::FakeAudioRenderCallback callback(0); | 304 media::FakeAudioRenderCallback callback(0, kSampleRate); |
| 305 scoped_refptr<media::AudioRendererMixerInput> input( | 305 scoped_refptr<media::AudioRendererMixerInput> input( |
| 306 manager_->CreateInput(kRenderFrameId, 0, kDefaultDeviceId, | 306 manager_->CreateInput(kRenderFrameId, 0, kDefaultDeviceId, |
| 307 kSecurityOrigin, AudioLatency::LATENCY_PLAYBACK)); | 307 kSecurityOrigin, AudioLatency::LATENCY_PLAYBACK)); |
| 308 input->Initialize(params, &callback); | 308 input->Initialize(params, &callback); |
| 309 EXPECT_EQ(0, mixer_count()); | 309 EXPECT_EQ(0, mixer_count()); |
| 310 media::FakeAudioRenderCallback another_callback(1); | 310 media::FakeAudioRenderCallback another_callback(1, kSampleRate); |
| 311 scoped_refptr<media::AudioRendererMixerInput> another_input( | 311 scoped_refptr<media::AudioRendererMixerInput> another_input( |
| 312 manager_->CreateInput(kAnotherRenderFrameId, 0, kDefaultDeviceId, | 312 manager_->CreateInput(kAnotherRenderFrameId, 0, kDefaultDeviceId, |
| 313 kSecurityOrigin, AudioLatency::LATENCY_PLAYBACK)); | 313 kSecurityOrigin, AudioLatency::LATENCY_PLAYBACK)); |
| 314 another_input->Initialize(params, &another_callback); | 314 another_input->Initialize(params, &another_callback); |
| 315 EXPECT_EQ(0, mixer_count()); | 315 EXPECT_EQ(0, mixer_count()); |
| 316 | 316 |
| 317 // Implicitly test that AudioRendererMixerInput was provided with the expected | 317 // Implicitly test that AudioRendererMixerInput was provided with the expected |
| 318 // callbacks needed to acquire an AudioRendererMixer and return it. | 318 // callbacks needed to acquire an AudioRendererMixer and return it. |
| 319 input->Start(); | 319 input->Start(); |
| 320 EXPECT_EQ(1, mixer_count()); | 320 EXPECT_EQ(1, mixer_count()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 344 EXPECT_CALL(*mock_sink_matched_device_.get(), Start()).Times(1); | 344 EXPECT_CALL(*mock_sink_matched_device_.get(), Start()).Times(1); |
| 345 EXPECT_CALL(*mock_sink_matched_device_.get(), Stop()).Times(1); | 345 EXPECT_CALL(*mock_sink_matched_device_.get(), Stop()).Times(1); |
| 346 | 346 |
| 347 // We expect 3 mixers to be created; each of them should release a sink. | 347 // We expect 3 mixers to be created; each of them should release a sink. |
| 348 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(2); | 348 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_.get())).Times(2); |
| 349 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_matched_device_.get())).Times(1); | 349 EXPECT_CALL(*this, ReleaseSinkPtr(mock_sink_matched_device_.get())).Times(1); |
| 350 | 350 |
| 351 media::AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, | 351 media::AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, |
| 352 kChannelLayout, kSampleRate, kBitsPerChannel, | 352 kChannelLayout, kSampleRate, kBitsPerChannel, |
| 353 kBufferSize); | 353 kBufferSize); |
| 354 media::FakeAudioRenderCallback callback(0); | 354 media::FakeAudioRenderCallback callback(0, kSampleRate); |
| 355 EXPECT_EQ(0, mixer_count()); | 355 EXPECT_EQ(0, mixer_count()); |
| 356 | 356 |
| 357 // Empty device id, zero session id; | 357 // Empty device id, zero session id; |
| 358 scoped_refptr<media::AudioRendererMixerInput> input_to_default_device( | 358 scoped_refptr<media::AudioRendererMixerInput> input_to_default_device( |
| 359 manager_->CreateInput(kRenderFrameId, 0, // session_id | 359 manager_->CreateInput(kRenderFrameId, 0, // session_id |
| 360 std::string(), kSecurityOrigin, | 360 std::string(), kSecurityOrigin, |
| 361 AudioLatency::LATENCY_PLAYBACK)); | 361 AudioLatency::LATENCY_PLAYBACK)); |
| 362 input_to_default_device->Initialize(params, &callback); | 362 input_to_default_device->Initialize(params, &callback); |
| 363 EXPECT_EQ(0, mixer_count()); | 363 EXPECT_EQ(0, mixer_count()); |
| 364 | 364 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 822 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
| 823 #else | 823 #else |
| 824 // Expect hardware buffer size. | 824 // Expect hardware buffer size. |
| 825 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 825 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
| 826 #endif | 826 #endif |
| 827 | 827 |
| 828 ReturnMixer(mixer); | 828 ReturnMixer(mixer); |
| 829 } | 829 } |
| 830 | 830 |
| 831 } // namespace content | 831 } // namespace content |
| OLD | NEW |