Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 15217002: Using native sampling rate and optimal buffer size for audio on Android. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_capturer.h" 5 #include "content/renderer/media/webrtc_audio_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "content/common/child_process.h" 11 #include "content/common/child_process.h"
12 #include "content/renderer/media/audio_device_factory.h" 12 #include "content/renderer/media/audio_device_factory.h"
13 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" 13 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h"
14 #include "content/renderer/media/webrtc_audio_device_impl.h" 14 #include "content/renderer/media/webrtc_audio_device_impl.h"
15 #include "media/audio/audio_util.h" 15 #include "media/audio/audio_util.h"
16 #include "media/audio/sample_rates.h" 16 #include "media/audio/sample_rates.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 // Supported hardware sample rates for input and output sides. 20 // Supported hardware sample rates for input and output sides.
21 #if defined(OS_WIN) || defined(OS_MACOSX) 21 #if defined(OS_WIN) || defined(OS_MACOSX)
22 // media::GetAudioInputHardwareSampleRate() asks the audio layer 22 // media::GetAudioInputHardwareSampleRate() asks the audio layer
23 // for its current sample rate (set by the user) on Windows and Mac OS X. 23 // for its current sample rate (set by the user) on Windows and Mac OS X.
24 // The listed rates below adds restrictions and WebRtcAudioDeviceImpl::Init() 24 // The listed rates below adds restrictions and WebRtcAudioDeviceImpl::Init()
25 // will fail if the user selects any rate outside these ranges. 25 // will fail if the user selects any rate outside these ranges.
26 static int kValidInputRates[] = {96000, 48000, 44100, 32000, 16000, 8000}; 26 static int kValidInputRates[] = {96000, 48000, 44100, 32000, 16000, 8000};
27 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 27 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
28 static int kValidInputRates[] = {48000, 44100}; 28 static int kValidInputRates[] = {48000, 44100};
29 #elif defined(OS_ANDROID) 29 #elif defined(OS_ANDROID)
30 static int kValidInputRates[] = {48000, 44100, 16000}; 30 static int kValidInputRates[] = {48000, 44100};
31 #else 31 #else
32 static int kValidInputRates[] = {44100}; 32 static int kValidInputRates[] = {44100};
33 #endif 33 #endif
34 34
35 static int GetBufferSizeForSampleRate(int sample_rate) { 35 static int GetBufferSizeForSampleRate(int sample_rate) {
36 int buffer_size = 0; 36 int buffer_size = 0;
37 #if defined(OS_WIN) || defined(OS_MACOSX) 37 #if defined(OS_WIN) || defined(OS_MACOSX)
38 // Use different buffer sizes depending on the current hardware sample rate. 38 // Use different buffer sizes depending on the current hardware sample rate.
39 if (sample_rate == 44100) { 39 if (sample_rate == 44100) {
40 // We do run at 44.1kHz at the actual audio layer, but ask for frames 40 // We do run at 44.1kHz at the actual audio layer, but ask for frames
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { 389 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const {
390 base::AutoLock auto_lock(lock_); 390 base::AutoLock auto_lock(lock_);
391 // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not 391 // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not
392 // been called. 392 // been called.
393 return buffer_.get() ? buffer_->params() : media::AudioParameters(); 393 return buffer_.get() ? buffer_->params() : media::AudioParameters();
394 } 394 }
395 395
396 } // namespace content 396 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/android/audio_manager_android.h » ('j') | media/audio/android/audio_manager_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698