Closed dturner closed 9 years ago
Thank you very much for your contribution. We will release the new version very soon with this included.
Please note, you need to check if the interface is available, otherwise your code will crash on devices with no such configuration support. So we did this:
// Configure the voice recognition preset which has no signal processing for lower latency.
SLAndroidConfigurationItf inputConfiguration;
if ((*inputBufferQueue)->GetInterface(inputBufferQueue, SL_IID_ANDROIDCONFIGURATION, &inputConfiguration) == SL_RESULT_SUCCESS) {
SLuint32 presetValue = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
(*inputConfiguration)->SetConfiguration(inputConfiguration, SL_ANDROID_KEY_RECORDING_PRESET,
&presetValue, sizeof(SLuint32));
(*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE);
};
Thanks for this. One thing: shouldn't (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE);
be outside the last parenthesis so that the input buffer queue is realized regardless of whether the VOICE_RECOGNITION preset is set?
Also, out of interest, which devices don't have this configuration support? Obviously non-Android devices but are there any Android devices you've tested which don't have this?
You are absolutely right, realize was on a wrong place. Fortunately, the media server initializes audio input still somehow. Will fix asap. The Samsung Note 3 crashed without checking for the interface.
Great, thanks for the info.
Some Android devices include signal processing by default on the MIC input, this increases latency and should be switched off.
For example, the new Nexus 6P has Dynamic Range Compression enabled by default which results in better quality audio input at the cost of increased latency. To switch this off you need to configure the MIC input to use the VOICE_RECOGNITION preset.
I have forked and updated the latency test to include this here: https://github.com/dturner/SuperpoweredLatency/commit/9b9408dfb073df3a80f0ca4a6570916b761228a8