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/webrtc_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/renderer/media/audio_device_factory.h" | 10 #include "content/renderer/media/audio_device_factory.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Supported hardware sample rates for output sides. | 27 // Supported hardware sample rates for output sides. |
28 #if defined(OS_WIN) || defined(OS_MACOSX) | 28 #if defined(OS_WIN) || defined(OS_MACOSX) |
29 // AudioHardwareConfig::GetOutputSampleRate() asks the audio layer for its | 29 // AudioHardwareConfig::GetOutputSampleRate() asks the audio layer for its |
30 // current sample rate (set by the user) on Windows and Mac OS X. The listed | 30 // current sample rate (set by the user) on Windows and Mac OS X. The listed |
31 // rates below adds restrictions and Initialize() will fail if the user selects | 31 // rates below adds restrictions and Initialize() will fail if the user selects |
32 // any rate outside these ranges. | 32 // any rate outside these ranges. |
33 const int kValidOutputRates[] = {96000, 48000, 44100, 32000, 16000}; | 33 const int kValidOutputRates[] = {96000, 48000, 44100, 32000, 16000}; |
34 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 34 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
35 const int kValidOutputRates[] = {48000, 44100}; | 35 const int kValidOutputRates[] = {48000, 44100}; |
36 #elif defined(OS_ANDROID) | 36 #elif defined(OS_ANDROID) |
37 // On Android, the most popular sampling rate is 16000. | 37 // TODO(leozwang): We want to use native sampling rate on Android to achieve |
| 38 // low latency, currently 16000 is used to work around audio problem on some |
| 39 // Android devices. |
38 const int kValidOutputRates[] = {48000, 44100, 16000}; | 40 const int kValidOutputRates[] = {48000, 44100, 16000}; |
39 #else | 41 #else |
40 const int kValidOutputRates[] = {44100}; | 42 const int kValidOutputRates[] = {44100}; |
41 #endif | 43 #endif |
42 | 44 |
43 // TODO(xians): Merge the following code to WebRtcAudioCapturer, or remove. | 45 // TODO(xians): Merge the following code to WebRtcAudioCapturer, or remove. |
44 enum AudioFramesPerBuffer { | 46 enum AudioFramesPerBuffer { |
45 k160, | 47 k160, |
46 k320, | 48 k320, |
47 k440, // WebRTC works internally with 440 audio frames at 44.1kHz. | 49 k440, // WebRTC works internally with 440 audio frames at 44.1kHz. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 344 } |
343 | 345 |
344 // De-interleave each channel and convert to 32-bit floating-point | 346 // De-interleave each channel and convert to 32-bit floating-point |
345 // with nominal range -1.0 -> +1.0 to match the callback format. | 347 // with nominal range -1.0 -> +1.0 to match the callback format. |
346 audio_bus->FromInterleaved(buffer_.get(), | 348 audio_bus->FromInterleaved(buffer_.get(), |
347 audio_bus->frames(), | 349 audio_bus->frames(), |
348 sizeof(buffer_[0])); | 350 sizeof(buffer_[0])); |
349 } | 351 } |
350 | 352 |
351 } // namespace content | 353 } // namespace content |
OLD | NEW |