4
votes

I'm working on a call recorder app using MediaRecorder VOICE_CALL audio source, In some marshmallow devices it's crashing, then I changed source to MIC here incoming voice is not getting recorded. Due to this java limitation now I'm working on native android code to record voice call. I'm managed to record the audio using native-audio recorder for call recorder. Problem is in native code also it's recording one side voice only,incoming voice is not getting recorded. Then I tried the voice communication preset configuration, its not recording. Below is the preset configuration code.

const SLInterfaceID id[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE,SL_IID_ANDROIDCONFIGURATION};
const SLboolean req[2] = { SL_BOOLEAN_TRUE,SL_BOOLEAN_TRUE};

result = (*engineEngine)->CreateAudioRecorder(engineEngine, &recorderObject, &audioSrc,
                                              &audioSnk, 2, id, req);

SLAndroidConfigurationItf inputConfig;
result = (*recorderObject)->GetInterface(recorderObject,
                                         SL_IID_ANDROIDCONFIGURATION,
                                         &inputConfig);


if (SL_RESULT_SUCCESS == result) {
    SLuint32 presetValue =SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ;
    (*inputConfig)->SetConfiguration(inputConfig,
                                     SL_ANDROID_KEY_RECORDING_PRESET,
                                     &presetValue,
                                     sizeof(SLuint32));
    __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "\n Native PCM Conf Success\n");

} else{
    __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "\n Native PCM Conf Error %d\n",result);

}

After adding preset configuration I'm getting system error when start recording the voice call :

E/AudioRecord: Could not get audio input for record source 7, sample rate 16000, format 0x1, channel mask 0x10, session 925, flags 0

E/libOpenSLES: android_audioRecorder_realize(0x559548c350) error creating AudioRecord object; status -22

W/libOpenSLES: Leaving Object::Realize (SL_RESULT_CONTENT_UNSUPPORTED)

1
Are you talking about github.com/googlesamples/android-ndk/tree/master/audio-echo this link but in my case audio file is not create with this codeBhanu Sharma
No I used this example: github.com/googlesamples/android-ndk/tree/master/native-audio, and during voice call I started recorder and on buffer stored file as .pcm inside sd-card. Check this link for saving to sdcard : stackoverflow.com/questions/18444354/…Bharath Kumar
means it not starting automatically? I run the code there is one button start so when I call tmo any one then i go to this appp and press button start then it will start record? Is which folder it put my file?Bhanu Sharma
You need to save buffer in sdcard, In your case it will keep the recorded file in the ram as buffer data. You need to put that native file in your call recorder app, and start recorder when call triggered.Bharath Kumar
Have you been able to solve that ?Paras Watts

1 Answers

0
votes

check documentation and set correct sampling rate, format and mask. Channel mask might be stereo or mono. I am not sure how you are getting status -22 error, but Realize error is very clear, as per documentation

SL_RESULT_CONTENT_UNSUPPORTED if a format is not supported (e.g. sample rate too high)

Look at NDK sample to clarify your parameter setup