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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 #if defined(OS_CHROMEOS) | 619 #if defined(OS_CHROMEOS) |
620 // Expecting input sample rate | 620 // Expecting input sample rate |
621 EXPECT_EQ(32000, mixer->GetOutputParamsForTesting().sample_rate()); | 621 EXPECT_EQ(32000, mixer->GetOutputParamsForTesting().sample_rate()); |
622 // Round up 20 ms (640) to the power of 2. | 622 // Round up 20 ms (640) to the power of 2. |
623 EXPECT_EQ(1024, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 623 EXPECT_EQ(1024, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
624 | 624 |
625 #else | 625 #else |
626 // Expecting hardware sample rate | 626 // Expecting hardware sample rate |
627 EXPECT_EQ(44100, mixer->GetOutputParamsForTesting().sample_rate()); | 627 EXPECT_EQ(44100, mixer->GetOutputParamsForTesting().sample_rate()); |
628 | 628 |
629 // 20 ms at 44100 is 882 frames per buffer. | 629 // 20 ms at 44100 is 882 frames per buffer. |
630 #if defined(OS_WIN) | |
631 // Round up 882 to the nearest multiple of the output buffer size (128). which | 630 // Round up 882 to the nearest multiple of the output buffer size (128). which |
632 // is 7 * 128 = 896 | 631 // is 7 * 128 = 896 |
633 EXPECT_EQ(896, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 632 EXPECT_EQ(896, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
634 #else | |
635 // Round up 882 to the power of 2. | |
636 EXPECT_EQ(1024, mixer->GetOutputParamsForTesting().frames_per_buffer()); | |
637 #endif // defined(OS_WIN) | |
638 | |
639 #endif // defined(OS_CHROMEOS) | 633 #endif // defined(OS_CHROMEOS) |
640 | 634 |
641 ReturnMixer(mixer); | 635 ReturnMixer(mixer); |
642 } | 636 } |
643 | 637 |
644 // Verify output bufer size of the mixer is correctly adjusted for Playback | 638 // Verify output bufer size of the mixer is correctly adjusted for Playback |
645 // latency when the device buffer size exceeds 20 ms. | 639 // latency when the device buffer size exceeds 20 ms. |
646 TEST_F(AudioRendererMixerManagerTest, | 640 TEST_F(AudioRendererMixerManagerTest, |
647 MixerParamsLatencyPlaybackLargeDeviceBufferSize) { | 641 MixerParamsLatencyPlaybackLargeDeviceBufferSize) { |
648 mock_sink_ = new media::MockAudioRendererSink( | 642 mock_sink_ = new media::MockAudioRendererSink( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 media::AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, | 686 media::AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, |
693 kChannelLayout, 32000, kBitsPerChannel, 512); | 687 kChannelLayout, 32000, kBitsPerChannel, 512); |
694 | 688 |
695 media::AudioRendererMixer* mixer = | 689 media::AudioRendererMixer* mixer = |
696 GetMixer(kRenderFrameId, params, AudioLatency::LATENCY_PLAYBACK, | 690 GetMixer(kRenderFrameId, params, AudioLatency::LATENCY_PLAYBACK, |
697 kDefaultDeviceId, kSecurityOrigin, nullptr); | 691 kDefaultDeviceId, kSecurityOrigin, nullptr); |
698 | 692 |
699 // Expecting input sample rate | 693 // Expecting input sample rate |
700 EXPECT_EQ(32000, mixer->GetOutputParamsForTesting().sample_rate()); | 694 EXPECT_EQ(32000, mixer->GetOutputParamsForTesting().sample_rate()); |
701 | 695 |
702 // 20 ms at 32000 is 640 frames per buffer. | 696 // 20 ms at 32000 is 640 frames per buffer. |
703 #if defined(OS_WIN) | |
704 // Use 20 ms buffer. | 697 // Use 20 ms buffer. |
705 EXPECT_EQ(640, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 698 EXPECT_EQ(640, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
706 #else | |
707 // Ignore device buffer size, round up 640 to the power of 2. | |
708 EXPECT_EQ(1024, mixer->GetOutputParamsForTesting().frames_per_buffer()); | |
709 #endif // defined(OS_WIN) | |
710 | 699 |
711 ReturnMixer(mixer); | 700 ReturnMixer(mixer); |
712 } | 701 } |
713 | 702 |
714 // Verify output bufer size of the mixer is correctly adjusted for RTC latency. | 703 // Verify output bufer size of the mixer is correctly adjusted for RTC latency. |
715 TEST_F(AudioRendererMixerManagerTest, MixerParamsLatencyRtc) { | 704 TEST_F(AudioRendererMixerManagerTest, MixerParamsLatencyRtc) { |
716 // Expecting hardware buffer size of 128 frames | 705 // Expecting hardware buffer size of 128 frames |
717 EXPECT_EQ(44100, | 706 EXPECT_EQ(44100, |
718 mock_sink_->GetOutputDeviceInfo().output_params().sample_rate()); | 707 mock_sink_->GetOutputDeviceInfo().output_params().sample_rate()); |
719 // Expecting hardware buffer size of 128 frames | 708 // Expecting hardware buffer size of 128 frames |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 811 EXPECT_EQ(2048, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
823 #else | 812 #else |
824 // Expect hardware buffer size. | 813 // Expect hardware buffer size. |
825 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer()); | 814 EXPECT_EQ(128, mixer->GetOutputParamsForTesting().frames_per_buffer()); |
826 #endif | 815 #endif |
827 | 816 |
828 ReturnMixer(mixer); | 817 ReturnMixer(mixer); |
829 } | 818 } |
830 | 819 |
831 } // namespace content | 820 } // namespace content |
OLD | NEW |