Android Open Source - webrtc-app-mono Audio Manager Android

From Project

Back to project page webrtc-app-mono.


The source code is released under:

Copyright (c) 2011, The WebRTC project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditi...

If you think the Android project webrtc-app-mono listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
 */*from   w w  w  .  j  av a2s .c  om*/
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.

// The functions in this file are called from native code. They can still be
// accessed even though they are declared private.

package org.webrtc.voiceengine;

import android.content.Context;

class AudioManagerAndroid {
  // Most of Google lead devices use 44.1K as the default sampling rate, 44.1K
  // is also widely used on other android devices.
  private static final int DEFAULT_SAMPLING_RATE = 44100;
  // Randomly picked up frame size which is close to return value on N4.
  // Return this default value when
  private static final int DEFAULT_FRAMES_PER_BUFFER = 256;

  private int mNativeOutputSampleRate;
  private boolean mAudioLowLatencySupported;
  private int mAudioLowLatencyOutputFrameSize;

  private AudioManagerAndroid(Context context) {
    AudioManager audioManager = (AudioManager)

    mNativeOutputSampleRate = DEFAULT_SAMPLING_RATE;
    mAudioLowLatencyOutputFrameSize = DEFAULT_FRAMES_PER_BUFFER;
    if (android.os.Build.VERSION.SDK_INT >=
        android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
      String sampleRateString = audioManager.getProperty(
      if (sampleRateString != null) {
        mNativeOutputSampleRate = Integer.parseInt(sampleRateString);
      String framesPerBuffer = audioManager.getProperty(
      if (framesPerBuffer != null) {
          mAudioLowLatencyOutputFrameSize = Integer.parseInt(framesPerBuffer);
    mAudioLowLatencySupported = context.getPackageManager().hasSystemFeature(

    private int getNativeOutputSampleRate() {
      return mNativeOutputSampleRate;

    private boolean isAudioLowLatencySupported() {
        return mAudioLowLatencySupported;

    private int getAudioLowLatencyOutputFrameSize() {
        return mAudioLowLatencyOutputFrameSize;

Java Source Code List