Created
September 23, 2010 06:02
-
-
Save intervigilium/593200 to your computer and use it in GitHub Desktop.
Android audio format autodetection code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do { | |
switch (sampleRate) { | |
case -1: | |
sampleRate = Constants.SAMPLE_RATE_22KHZ; | |
break; | |
case Constants.SAMPLE_RATE_44KHZ: | |
sampleRate = Constants.SAMPLE_RATE_22KHZ; | |
break; | |
case Constants.SAMPLE_RATE_22KHZ: | |
sampleRate = Constants.SAMPLE_RATE_11KHZ; | |
break; | |
case Constants.SAMPLE_RATE_11KHZ: | |
sampleRate = Constants.SAMPLE_RATE_8KHZ; | |
break; | |
default: | |
Log.w("AudioHelper", String.format("Hardware does not support recording!")); | |
DialogHelper.showWarning(context, R.string.unable_to_configure_audio_title, R.string.unable_to_configure_audio_warning); | |
return; | |
} | |
bufferSize = AudioRecord.getMinBufferSize( | |
sampleRate, | |
Constants.DEFAULT_CHANNEL_CONFIG, | |
Constants.DEFAULT_PCM_FORMAT); | |
} while (bufferSize == AudioRecord.ERROR_BAD_VALUE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment