Skip to content
Snippets Groups Projects
Commit 7351dad0 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

Set recorder streamType to SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION

Offered since ANDROID 14

Refs #45605
parent 3f0960e1
No related branches found
No related tags found
No related merge requests found
...@@ -339,12 +339,15 @@ OpenSLLayer::initAudioCapture() ...@@ -339,12 +339,15 @@ OpenSLLayer::initAudioCapture()
// create audio recorder // create audio recorder
// (requires the RECORD_AUDIO permission) // (requires the RECORD_AUDIO permission)
DEBUG("Create audio recorder\n"); DEBUG("Create audio recorder\n");
const SLInterfaceID id[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE}; const SLInterfaceID id[2] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
const SLboolean req[] = {SL_BOOLEAN_TRUE}; SL_IID_ANDROIDCONFIGURATION};
const SLboolean req[2] ={SL_BOOLEAN_TRUE,
SL_BOOLEAN_TRUE};
SLAndroidConfigurationItf recorderConfig;
if (engineInterface_ != nullptr) { if (engineInterface_ != nullptr) {
result = (*engineInterface_)->CreateAudioRecorder(engineInterface_, result = (*engineInterface_)->CreateAudioRecorder(engineInterface_,
&recorderObject_, &audioSource, &audioSink, 1, id, req); &recorderObject_, &audioSource, &audioSink, 2, id, req);
} }
if (SL_RESULT_SUCCESS != result) { if (SL_RESULT_SUCCESS != result) {
...@@ -352,6 +355,22 @@ OpenSLLayer::initAudioCapture() ...@@ -352,6 +355,22 @@ OpenSLLayer::initAudioCapture()
return; 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 // realize the audio recorder
DEBUG("Realize the audio recorder\n"); DEBUG("Realize the audio recorder\n");
result = (*recorderObject_)->Realize(recorderObject_, SL_BOOLEAN_FALSE); result = (*recorderObject_)->Realize(recorderObject_, SL_BOOLEAN_FALSE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment