1

我正在尝试编译我的 jnicode 它显示错误

_JNIEnv::GetShortArrayElements(JNIEnv*&, _jshortArray*&, int)'

我的代码是:

extern "C" JNIEXPORT jint Java_com_techgentsia_sound_Opusmain_nativeDecodeBytes (JNIEnv *env, jobject thiz,jbyteArray decoder_insrc,jshortArray decoder_out)
{
    int frame_size=320;

    jshort* pcm_data_decoder=env->GetShortArrayElements(env, decoder_out,0);

    jbyte* opus_data_decoder=env->GetByteArrayElements(env, decoder_insrc,0);  
}

编译器中的错误是:

/home/clifford/opusbuild/jni/opus/com_techgentsia_sound_Opusmain.cpp:117:72: error: no matching function for call to '_JNIEnv::GetShortArrayElements(JNIEnv*&, _jshortArray*&, int)'
/home/clifford/opusbuild/jni/opus/com_techgentsia_sound_Opusmain.cpp:117:72: note: candidate is:
/home/clifford/apps/android-ndk-r10/platforms/android-9/arch-arm/usr/include    /jni.h:921:13: note: jshort* _JNIEnv::GetShortArrayElements(jshortArray, jboolean*)
/home/clifford/apps/android-ndk-r10/platforms/android-9/arch-arm/usr/include/jni.h:921:13: note:   candidate expects 2 arguments, 3 provided
4

1 回答 1

0

我解决了问题更改代码如下。

                                                                                                                          extern "C" JNIEXPORT jint Java_com_techgentsia_sound_Opusmain_nativeDecodeBytes (JNIEnv *env, jobject thiz,jbyteArray decoder_insrc,jshortArray decoder_out)

{ int frame_size=320;

jshort* pcm_data_decoder=env->GetShortArrayElements( decoder_out,0);

jbyte* opus_data_decoder=env->GetByteArrayElements( decoder_insrc,0);  

}

我们不需要在这个方法中传递 env GetShortArrayElements(decoder_out,0); GetByteArrayElements(decoder_insrc,0);
因为我正在写 cpp 类

于 2014-12-04T08:37:25.090 回答