Android examples for android.media:Audio
Check correct buffer size for your AudioRecord instance
import android.media.AudioRecord; public class Main { /**/* ww w. ja v a 2s . com*/ * Check correct buffer size for your AudioRecord instance * * @param audioSource * the audio source * @param fs * the fs * @param channelConfiguration * the channel configuration * @param audioEncoding * the audio encoding * @return the int */ public static int checkCorrectBufferSize(int audioSource, int fs, int channelConfiguration, int audioEncoding) { for (int buffer : new int[] { 256, 512, 1024, 2048, 4096 }) { // add the rates you wish to check against AudioRecord audioRecordTemp = new AudioRecord(audioSource, fs, channelConfiguration, audioEncoding, buffer); if (audioRecordTemp != null && audioRecordTemp.getState() == AudioRecord.STATE_INITIALIZED) { return buffer; } } return 0; } }