I’m porting an audio capture loop from Java (using AudioRecord class) to a native library using OpenSL.
The reason for this is that after profiling, the capture loop is consuming in our test phones around 2% less CPU in OpenSL. That is a significative gain!
The constructor for the Java AudioRecord class receives a source parameter that can be configured to several values (MIC, CAMCORDER, VOICE_DOWNLINK, etc.)
So far, I haven’t been able to find the equivalence (if there exists) for the source parameter in OpenSL.
Does anybody know if there’s a way to specify this Source parameter for the AudioRecorder object?
Cheers!
Check out the functions and constants defined in
SLES/OpenSLES_Android.handSLES/OpenSLES_AndroidConfiguration.h. When you get your recording object from OpenSLES, useGetInterface()to get the interface pointer forSL_IID_ANDROIDCONFIGURATION. From there you can callSetConfiguration()using keySL_ANDROID_KEY_RECORDING_PRESETon the returnedSLAndroidConfigurationItfpointer.