Commit 7351dad0 authored by Alexandre Lision's avatar Alexandre Lision

Set recorder streamType to SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION

Offered since ANDROID 14

Refs #45605
parent 3f0960e1
......@@ -339,12 +339,15 @@ OpenSLLayer::initAudioCapture()
// create audio recorder
// (requires the RECORD_AUDIO permission)
DEBUG("Create audio recorder\n");
const SLInterfaceID id[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
const SLboolean req[] = {SL_BOOLEAN_TRUE};
const SLInterfaceID id[2] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
SL_IID_ANDROIDCONFIGURATION};
const SLboolean req[2] ={SL_BOOLEAN_TRUE,
SL_BOOLEAN_TRUE};
SLAndroidConfigurationItf recorderConfig;
if (engineInterface_ != nullptr) {
result = (*engineInterface_)->CreateAudioRecorder(engineInterface_,
&recorderObject_, &audioSource, &audioSink, 1, id, req);
&recorderObject_, &audioSource, &audioSink, 2, id, req);
}
if (SL_RESULT_SUCCESS != result) {
......@@ -352,6 +355,22 @@ OpenSLLayer::initAudioCapture()
return;
}
/* Set Android configuration */
result = (*recorderObject_)->GetInterface(recorderObject_,
SL_IID_ANDROIDCONFIGURATION,
&recorderConfig);
if (result == SL_RESULT_SUCCESS) {
SLint32 streamType = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
result = (*recorderConfig)->SetConfiguration(
recorderConfig, SL_ANDROID_KEY_RECORDING_PRESET,
&streamType, sizeof(SLint32));
}
if (result != SL_RESULT_SUCCESS) {
DEBUG("Warning: Unable to set android recorder configuration");
return;
}
// realize the audio recorder
DEBUG("Realize the audio recorder\n");
result = (*recorderObject_)->Realize(recorderObject_, SL_BOOLEAN_FALSE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment