我在返回线上收到错误。我的代码:
extern "C" DLL_PUBLIC jbyteArray Java_com_ngochoang_playerdemo_AudioNativeLib_navProcessBytes(JNIEnv *env, jobject thiz, jbyteArray data, jint size)
{
LOGV("JNI call soundtouch.navProcessBytes");
int bufferSize = size*5;
SAMPLETYPE sampleBuffer[bufferSize];
pSoundTouch.putSamples((SAMPLETYPE*)data, size);
TotalNSamples = pSoundTouch.receiveSamples(sampleBuffer, bufferSize);
LOGV("JNI call soundtouch.navProcessBytes END");
return (jbyteArray)sampleBuffer;
}
错误:
致命信号11(SIGSEGV)位于0xdeadd00d(代码= 1),线程5980(线程-753)
由于
答案 0 :(得分:0)
我解决了我的问题。
extern "C" DLL_PUBLIC jbyteArray Java_com_ngochoang_playerdemo_AudioNativeLib_navProcessBytes(JNIEnv *env, jobject thiz, jbyteArray data, jint size)
{
LOGV("JNI call soundtouch.navProcessBytes");
int bufferSize = size*5;
SAMPLETYPE sampleBuffer[bufferSize];
pSoundTouch.putSamples((SAMPLETYPE*)data, size);
TotalNSamples = pSoundTouch.receiveSamples(sampleBuffer, bufferSize);
jbyteArray ret = env->NewByteArray(bufferSize);
env->SetByteArrayRegion(ret, 0, bufferSize, (jbyte *)sampleBuffer);
LOGV("JNI call soundtouch.navProcessBytes END");
return ret;
}
需要使用JNI函数SetByteArrayRegion复制到jbyteArray