Home > Net >  why visualizer.getfft excites java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: jarray was NULL
why visualizer.getfft excites java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: jarray was NULL

Time:11-01

I think this is a very difficult question and I need a very experienced specialist, so if you can answer in advance, thank you very much :D

audioVisualizer = new AudioVisualizer(audioSessionId);
audioVisualizer.setEnabled(true);
try {
//  Exception ||||||||||||||||||||||||||
    int a = audioVisualizer.getFft(fft);
//  Exception ||||||||||||||||||||||||||
}catch (Exception e){
    e.printStackTrace();
}

if you need all Exception code :

java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: jarray was NULL
2022-10-31 22:15:16.153 18560-18560 m.example.musi          com.example.music                    A  java_vm_ext.cc:570]     in call to GetPrimitiveArrayCritical
2022-10-31 22:15:16.153 18560-18560 m.example.musi          com.example.music                    A  java_vm_ext.cc:570]     from int android.media.audiofx.Visualizer.native_getFft(byte[])
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630] Runtime aborting...
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630] Dumping all threads without mutator lock held
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630] All threads:
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630] DALVIK THREADS (16):
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630] "main" prio=10 tid=1 Runnable
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630]   | group="" sCount=0 dsCount=0 flags=0 obj=0x72693e78 self=0x7490846c00
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630]   | sysTid=18560 nice=-10 cgrp=default sched=0/0 handle=0x7491fa7ed0
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630]   | state=R schedstat=( 5524140844 782691092 6362 ) utm=512 stm=40 core=3 HZ=100
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630]   | stack=0x7fdcf36000-0x7fdcf38000 stackSize=8192KB
2022-10-31 22:15:16.595 18560-18560 m.example.musi          com.example.music                    A  runtime.cc:630]   | held mutexes= "abort lock" "mutator lock"(shared held)

I googled and looked at stack overflows to no avail

CodePudding user response:

fft must be an array of bytes where the FFT can be returned. If your class just has a field declaration like byte[] fft; then fft is null and audioVisualizer.getFft() has no place to store the captured FFT.

You must provide a byte array that is large enough (audioVisualizer.getCaptureSize()).

Your code must contain these lines:

int n = audioVisualizer.getCaptureSize();
fft = new byte[n];
int a = audioVisualizer.getFft(fft);
  • Related