| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "build/build_config.h" |
| 5 #include "media/base/audio_hardware_config.h" | 6 #include "media/base/audio_hardware_config.h" |
| 6 #include "media/audio/audio_parameters.h" | 7 #include "media/audio/audio_parameters.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace media { | 10 namespace media { |
| 10 | 11 |
| 11 static const int kOutputBufferSize = 2048; | 12 static const int kOutputBufferSize = 2048; |
| 12 static const int kOutputSampleRate = 48000; | 13 static const int kOutputSampleRate = 48000; |
| 13 static const ChannelLayout kOutputChannelLayout = CHANNEL_LAYOUT_STEREO; | 14 static const ChannelLayout kOutputChannelLayout = CHANNEL_LAYOUT_STEREO; |
| 14 static const int kInputSampleRate = 44100; | 15 static const int kInputSampleRate = 44100; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 AudioParameters::AUDIO_PCM_LOW_LATENCY, | 81 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 81 kNewInputChannelLayout, | 82 kNewInputChannelLayout, |
| 82 kNewInputSampleRate, | 83 kNewInputSampleRate, |
| 83 16, | 84 16, |
| 84 kOutputBufferSize); | 85 kOutputBufferSize); |
| 85 fake_config.UpdateInputConfig(new_input_params); | 86 fake_config.UpdateInputConfig(new_input_params); |
| 86 EXPECT_EQ(kNewInputSampleRate, fake_config.GetInputSampleRate()); | 87 EXPECT_EQ(kNewInputSampleRate, fake_config.GetInputSampleRate()); |
| 87 EXPECT_EQ(kNewInputChannelLayout, fake_config.GetInputChannelLayout()); | 88 EXPECT_EQ(kNewInputChannelLayout, fake_config.GetInputChannelLayout()); |
| 88 } | 89 } |
| 89 | 90 |
| 91 TEST(AudioHardwareConfig, HighLatencyBufferSizes) { |
| 92 AudioParameters input_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 93 kInputChannelLayout, |
| 94 kInputSampleRate, |
| 95 16, |
| 96 kOutputBufferSize); |
| 97 AudioParameters output_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 98 kOutputChannelLayout, |
| 99 3200, |
| 100 16, |
| 101 32); |
| 102 AudioHardwareConfig fake_config(input_params, output_params); |
| 103 |
| 104 #if defined(OS_LINUX) |
| 105 EXPECT_EQ(64, fake_config.GetHighLatencyBufferSize()); |
| 106 |
| 107 for (int i = 6400; i <= 204800; i *= 2) { |
| 108 fake_config.UpdateOutputConfig( |
| 109 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 110 kOutputChannelLayout, |
| 111 i, |
| 112 16, |
| 113 32)); |
| 114 EXPECT_EQ(2 * (i / 100), fake_config.GetHighLatencyBufferSize()); |
| 115 } |
| 116 #else |
| 117 // If high latency buffer sizes are not supported, the value should just pass |
| 118 // through the output buffer size. |
| 119 EXPECT_EQ(32, fake_config.GetHighLatencyBufferSize()); |
| 120 #endif |
| 121 } |
| 122 |
| 90 } // namespace content | 123 } // namespace content |
| OLD | NEW |