libvorbis-libogg-android中的本地引用表溢出(max = 512)

时间:2015-12-24 07:20:29

标签: android c++ c java-native-interface

请帮助我,我正在我的项目中使用libvorbis-libogg-android录制语音并编码到ogg。当我的录音超过30秒我的应用程序崩溃时,

private class AsyncEncoding implements Runnable {
@Override
public void run() {
    //Start the native encoder
    Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_AUDIO);
    int result = 0;
    switch (recordingType) {
        case WITH_BITRATE:
            result = VorbisEncoder.startEncodingWithBitrate(sampleRate, numberOfChannels, bitrate, encodeFeed);
            break;
        case WITH_QUALITY:
            result = VorbisEncoder.startEncodingWithQuality(sampleRate, numberOfChannels, quality, encodeFeed);
            break;
    }
    switch (result) {
        case EncodeFeed.SUCCESS:
            Log.d(TAG, "Encoder successfully finished");
            recordHandler.sendEmptyMessage(FINISHED_SUCCESSFULLY);
            break;
        case EncodeFeed.ERROR_INITIALIZING:
            recordHandler.sendEmptyMessage(ERROR_INITIALIZING);
            Log.e(TAG, "There was an error initializing the native encoder");
            break;
        default:
            recordHandler.sendEmptyMessage(FAILED_FOR_UNKNOWN_REASON);
            Log.e(TAG, "Encoder returned an unknown result code");
            break;
    }
}

}

和我的错误

12-24 10:15:05.508 13519-15770/com.example.idek_2.testogg A/art: art/runtime/indirect_reference_table.cc:98] JNI ERROR (app bug): local reference table overflow (max=512)
12-24 10:15:05.508 13519-15770/com.example.idek_2.testogg A/art: art/runtime/indirect_reference_table.cc:98] local reference table dump:
12-24 10:15:05.508 13519-15770/com.example.idek_2.testogg A/art: art/runtime/indirect_reference_table.cc:98]   Last 10 entries (of 512):
....
 12-24 10:15:05.784 13519-15770/com.example.idek_2.testogg A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 15770 (Thread-31146)

我认为我的问题在这里因为在这里创建表https://github.com/vincentjames501/libvorbis-libogg-android/blob/master/jni/libvorbis-jni/org_xiph_vorbis_encoder_VorbisEncoder.c

1 个答案:

答案 0 :(得分:0)

我认为本地引用表是指JNI VM本身。在内部,JNI维护对象的参考表,我怀疑你在没有释放它们的情况下使用了太多。如果是别人写的代码,那么你应该向他们报告一些可能的错误。

如果您自己进行调查,请尝试阅读JNI文档,特别注意与全局和本地引用相关的调用,尤其是DeleteLocalRef函数。