我想用jni在c层直接调用音频设置录音,在网上找了例子边研究,边编写代码时,发现
SL_IID_ANDROIDSIMPLEBUFFERQUEUE这个预定义变量只有声明,没有值,导致我编译不通过
提示 Error:(178) undefined reference to 'SL_IID_ANDROIDSIMPLEBUFFERQUEUE'
而我检查过代码了,已经include相关的头文件了
我是c菜鸟,望大神指点迷津!
代码如下
int initNativeRecorder(){
SLresult f_result;
SLDataLocator_IODevice loc_dev={SL_DATALOCATOR_IODEVICE,SL_IODEVICE_AUDIOINPUT,SL_DEFAULTDEVICEID_AUDIOINPUT,NULL};
SLDataSource aud_src = {&loc_dev,NULL};
LOGE("Setup Audio Input Dev! OK!");
SLDataLocator_AndroidSimpleBufferQueue mQueue = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,2};
SLDataFormat_PCM mFormat = {SL_DATAFORMAT_PCM,1,SL_SAMPLINGRATE_16,SL_PCMSAMPLEFORMAT_FIXED_16,SL_PCMSAMPLEFORMAT_FIXED_16,SL_SPEAKER_FRONT_CENTER,SL_BYTEORDER_LITTLEENDIAN};
SLDataSink mAudSink = {&mQueue,&mFormat};
LOGE("Configure Audio Recorder! OK!");
const SLInterfaceID mId[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
const SLboolean mReq[1] = {SL_BOOLEAN_TRUE};
LOGE("Open Audio Device To Recorder! OK!");
f_result = (*m_Engine)->CreateAudioRecorder(m_Engine,&m_RecordObject,&aud_src,&mAudSink,1,mId,mReq);
return 0;
}
应该是linking时找不到OpenSLES库,检查你的.mk档看看