我正在使用MediaRecorder VOICE_CALL音频源处理一个呼叫记录器应用程序,在一些marshmallow设备中它正在崩溃,然后我将源更改为MIC,这里传入的语音没有被记录.由于这个
java限制现在我正在使用原生的android代码来录制语音通话.
我设法使用
native-audio录音机为录音机录制音频.问题出在本机代码中,它只记录单侧语音,传入的语音没有被记录.然后我尝试了语音通信预设配置,它没有录音.以下是预设配置代码.
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);
}
添加预设配置后,开始录制语音通话时出现系统错误:
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)