From 48c46dbad202d190b8a76967908df32516015316 Mon Sep 17 00:00:00 2001 From: henrika Date: Thu, 17 Sep 2015 15:59:55 +0200 Subject: [PATCH] Reduces default sample rate from 44.1kHz to 16kHz to ensure that we can open up audio in communication mode also on older devices that only supports it in combination with 16kHz. BUG=webrtc:4756 R=magjed@webrtc.org Review URL: https://codereview.webrtc.org/1347243003 . Cr-Commit-Position: refs/heads/master@{#9971} --- .../org/webrtc/voiceengine/WebRtcAudioManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java index 81a2bddcd7..2bd840084d 100644 --- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java +++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java @@ -42,8 +42,11 @@ class WebRtcAudioManager { // Guaranteed to be supported by all devices. private static final int BITS_PER_SAMPLE = 16; - // Use 44.1kHz as the default sampling rate. - private static final int SAMPLE_RATE_HZ = 44100; + // Use 16kHz as the default sample rate. A higher sample rate might prevent + // us from supporting communication mode on some older (e.g. ICS) devices. + private static final int DEFAULT_SAMPLE_RATE_HZ = 16000; + + private static final int DEFAULT_FRAME_PER_BUFFER = 256; // TODO(henrika): add stereo support for playout. private static final int CHANNELS = 1; @@ -56,8 +59,6 @@ class WebRtcAudioManager { "MODE_IN_COMMUNICATION", }; - private static final int DEFAULT_FRAME_PER_BUFFER = 256; - private final long nativeAudioManager; private final Context context; private final AudioManager audioManager; @@ -166,12 +167,12 @@ class WebRtcAudioManager { return 8000; } if (!WebRtcAudioUtils.runningOnJellyBeanMR1OrHigher()) { - return SAMPLE_RATE_HZ; + return DEFAULT_SAMPLE_RATE_HZ; } String sampleRateString = audioManager.getProperty( AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); return (sampleRateString == null) ? - SAMPLE_RATE_HZ : Integer.parseInt(sampleRateString); + DEFAULT_SAMPLE_RATE_HZ : Integer.parseInt(sampleRateString); } // Returns the native output buffer size for low-latency output streams.