3

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!

1 Answers1

4

Check out the functions and constants defined in SLES/OpenSLES_Android.h and SLES/OpenSLES_AndroidConfiguration.h. When you get your recording object from OpenSLES, use GetInterface() to get the interface pointer for SL_IID_ANDROIDCONFIGURATION. From there you can call SetConfiguration() using key SL_ANDROID_KEY_RECORDING_PRESET on the returned SLAndroidConfigurationItf pointer.

kelnos
  • 874
  • 5
  • 11
  • Thank you very much @kelnos, this is exactly what I was looking for - there's very little documentation available on the subject! –  Sep 07 '12 at 15:49
  • Yeah, for me it was a bit of trial and error and poking around at headers, as well as finding some code out in the wild that did something similar. The documentation is terrible! – kelnos Sep 09 '12 at 11:12