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

Side by Side Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java

Issue 1347243003: Reduces default sample rate from 44.1kHz to 16kHz (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 24 matching lines...) Expand all
35 // STREAM_VOICE_CALL-type stream. 35 // STREAM_VOICE_CALL-type stream.
36 class WebRtcAudioManager { 36 class WebRtcAudioManager {
37 private static final boolean DEBUG = false; 37 private static final boolean DEBUG = false;
38 38
39 private static final String TAG = "WebRtcAudioManager"; 39 private static final String TAG = "WebRtcAudioManager";
40 40
41 // Default audio data format is PCM 16 bit per sample. 41 // Default audio data format is PCM 16 bit per sample.
42 // Guaranteed to be supported by all devices. 42 // Guaranteed to be supported by all devices.
43 private static final int BITS_PER_SAMPLE = 16; 43 private static final int BITS_PER_SAMPLE = 16;
44 44
45 // Use 44.1kHz as the default sampling rate. 45 // Use 16kHz as the default sample rate. A higher sample rate might prevent
46 private static final int SAMPLE_RATE_HZ = 44100; 46 // us from supporting communication mode on some older (e.g. ICS) devices.
47 private static final int DEFAULT_SAMPLE_RATE_HZ = 16000;
48
49 private static final int DEFAULT_FRAME_PER_BUFFER = 256;
47 50
48 // TODO(henrika): add stereo support for playout. 51 // TODO(henrika): add stereo support for playout.
49 private static final int CHANNELS = 1; 52 private static final int CHANNELS = 1;
50 53
51 // List of possible audio modes. 54 // List of possible audio modes.
52 private static final String[] AUDIO_MODES = new String[] { 55 private static final String[] AUDIO_MODES = new String[] {
53 "MODE_NORMAL", 56 "MODE_NORMAL",
54 "MODE_RINGTONE", 57 "MODE_RINGTONE",
55 "MODE_IN_CALL", 58 "MODE_IN_CALL",
56 "MODE_IN_COMMUNICATION", 59 "MODE_IN_COMMUNICATION",
57 }; 60 };
58 61
59 private static final int DEFAULT_FRAME_PER_BUFFER = 256;
60
61 private final long nativeAudioManager; 62 private final long nativeAudioManager;
62 private final Context context; 63 private final Context context;
63 private final AudioManager audioManager; 64 private final AudioManager audioManager;
64 65
65 private boolean initialized = false; 66 private boolean initialized = false;
66 private int nativeSampleRate; 67 private int nativeSampleRate;
67 private int nativeChannels; 68 private int nativeChannels;
68 69
69 private boolean hardwareAEC; 70 private boolean hardwareAEC;
70 private boolean lowLatencyOutput; 71 private boolean lowLatencyOutput;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 // Returns the native output sample rate for this device's output stream. 161 // Returns the native output sample rate for this device's output stream.
161 private int getNativeOutputSampleRate() { 162 private int getNativeOutputSampleRate() {
162 // Override this if we're running on an old emulator image which only 163 // Override this if we're running on an old emulator image which only
163 // supports 8 kHz and doesn't support PROPERTY_OUTPUT_SAMPLE_RATE. 164 // supports 8 kHz and doesn't support PROPERTY_OUTPUT_SAMPLE_RATE.
164 if (WebRtcAudioUtils.runningOnEmulator()) { 165 if (WebRtcAudioUtils.runningOnEmulator()) {
165 Logd("Running on old emulator, overriding sampling rate to 8 kHz."); 166 Logd("Running on old emulator, overriding sampling rate to 8 kHz.");
166 return 8000; 167 return 8000;
167 } 168 }
168 if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) { 169 if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) {
169 return SAMPLE_RATE_HZ; 170 return DEFAULT_SAMPLE_RATE_HZ;
170 } 171 }
171 String sampleRateString = audioManager.getProperty( 172 String sampleRateString = audioManager.getProperty(
172 AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); 173 AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
173 return (sampleRateString == null) ? 174 return (sampleRateString == null) ?
174 SAMPLE_RATE_HZ : Integer.parseInt(sampleRateString); 175 DEFAULT_SAMPLE_RATE_HZ : Integer.parseInt(sampleRateString);
175 } 176 }
176 177
177 // Returns the native output buffer size for low-latency output streams. 178 // Returns the native output buffer size for low-latency output streams.
178 private int getLowLatencyOutputFramesPerBuffer() { 179 private int getLowLatencyOutputFramesPerBuffer() {
179 assertTrue(isLowLatencyOutputSupported()); 180 assertTrue(isLowLatencyOutputSupported());
180 if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) { 181 if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) {
181 return DEFAULT_FRAME_PER_BUFFER; 182 return DEFAULT_FRAME_PER_BUFFER;
182 } 183 }
183 String framesPerBuffer = audioManager.getProperty( 184 String framesPerBuffer = audioManager.getProperty(
184 AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); 185 AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 251
251 private static void Loge(String msg) { 252 private static void Loge(String msg) {
252 Logging.e(TAG, msg); 253 Logging.e(TAG, msg);
253 } 254 }
254 255
255 private native void nativeCacheAudioParameters( 256 private native void nativeCacheAudioParameters(
256 int sampleRate, int channels, boolean hardwareAEC, boolean lowLatencyOutput, 257 int sampleRate, int channels, boolean hardwareAEC, boolean lowLatencyOutput,
257 int outputBufferSize, int inputBufferSize, 258 int outputBufferSize, int inputBufferSize,
258 long nativeAudioManager); 259 long nativeAudioManager);
259 } 260 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698