To get the preferred audio buffer size and audio sample rate for a given Android device, you can execute the following Java code:
// To get preferred buffer size and sampling rate.
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
Log.d("Buffer Size and sample rate", "Size :" + size + " & Rate: " + rate);
Is it possible to do this in C/C++ instead?
If so, how?
The openSLES API doesn't seem to offer this feature. I did notice that openSLES.h defines an SLAudioInputDescriptor struct as well as an SLAudioOutputDescriptor, but if this is available on Android I am not sure how to get the supported microphone and speaker sample rates. Also, the struct doesn't contain info about preferred buffer size.