0

I get an error at the return line. My code:

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;
}

Error:

Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 5980 (Thread-753)

Thanks

mmdc
  • 1,677
  • 3
  • 20
  • 32
  • There is also a warning before this error: "10-24 12:37:07.149: W/dalvikvm(5893): Invalid indirect reference 0x49deb9b0 in decodeIndirectRef" – mmdc Oct 24 '13 at 11:41
  • Hello! Wow. Have you wrote working project with SoundTouch?? Respect! Could you share some test project (set pcm data (bytes or shorts), pitch shifting, and get back out data for playing in AudioTrack) kulykvp@gmail.com TY!! –  Jan 09 '14 at 15:59
  • Sorry, I cannot share the project's code with you because it is closed source and commercial product. However, I am glad to help you if you have problem with it. Cheers!! – mmdc Jan 09 '14 at 16:52
  • I have correct includes. I need help with SoundTouch using, i meen jni method, where I can put byte[] and PithValue, and get out byte[]. I already can get pcm for putting in SoundTouch, and play out byte[] in AudioTrack. All I need, it's correct method. TY!~! –  Jan 10 '14 at 11:47

1 Answers1

0

I fixed my problem.

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;
}

it's needed copy into jbyteArray by using JNI function SetByteArrayRegion

mmdc
  • 1,677
  • 3
  • 20
  • 32