I'm working with OpenSL_ES
in Android, and having some issues with the mic source selection in Samsung devices when I connect earphones with handsfree.
The problem is that no matter what mic source I set in OpenSL_ES
, the gain configuration changes but the mic is always the handsfree mic. In other words, I cannot use the device built-in mic when I connect a handsfree device.
I have tried:
Changing the mic source to all available sources:
//ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_NONE;
//ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_GENERIC;
ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_CAMCORDER;
//ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
//ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
//ioInternals.micSource = SL_ANDROID_RECORDING_PRESET_UNPROCESSED;
res = (*recorderConfig)->SetConfiguration(recorderConfig, SL_ANDROID_KEY_RECORDING_PRESET,&ioInternals.micSource, sizeof(SLuint32));
None of the above allows me to change source (only gain configuration)
Some where I've read that a "hack" could be set to SL_ANDROID_RECORDING_PRESET_NONE
in OpenSL_ES
and then use MediaRecorder class in Java to prepare a recorder while changing the mic sources (which are like 9) to check if one of them would make the phone change the source to the device built-in mic and so OpenSL_ES
would take the default mic at the moment. This doesn't make too much sense as they are working in different contexts, but took the time to make a test, and MediaRecorder does not change the mic source when handsfree is connected neither.
An option I see is to develop my mic module in Jack library from Samsung assuming that library can change the mic source. However I'm not certain that it is possible.
Question: Do you know how I can resolve this issue?
I have seen a few apps that manage to make this work, but I have no idea what they are doing to accomplish the task.