I've set a breakpoint and stepped through the code and it's definitely not the setDataCaptureListener function. If I step into
Code:
mVisualizer = new Visualizer(0);
then I can see the native_setup function (line 9) returning the -3 error code. I can't step into this function though to see what's going on.
Code:
public Visualizer(int audioSession)
throws UnsupportedOperationException, RuntimeException {
int[] id = new int[1];
synchronized (mStateLock) {
mState = STATE_UNINITIALIZED;
// native initialization
int result = native_setup(new WeakReference<Visualizer>(this), audioSession, id,
ActivityThread.currentOpPackageName());
if (result != SUCCESS && result != ALREADY_EXISTS) {
Log.e(TAG, "Error code "+result+" when initializing Visualizer.");
switch (result) {
case ERROR_INVALID_OPERATION:
throw (new UnsupportedOperationException("Effect library not loaded"));
default:
throw (new RuntimeException("Cannot initialize Visualizer engine, error: "
+result));
}
}
mId = id[0];
if (native_getEnabled()) {
mState = STATE_ENABLED;
} else {
mState = STATE_INITIALIZED;
}
}
}
Here is the stack trace from the exception:
02-16 09:11:44.615 16933-16933/com.alexpech.visualisertest E/AudioEffect: set(): AudioFlinger could not create effect, status: -1
02-16 09:11:44.615 16933-16933/com.alexpech.visualisertest E/visualizers-JNI: Visualizer initCheck failed -3
02-16 09:11:44.615 16933-16933/com.alexpech.visualisertest E/Visualizer-JAVA: Error code -3 when initializing Visualizer.
02-16 09:11:44.617 16933-16933/com.alexpech.visualisertest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.alexpech.visualisertest, PID: 16933
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alexpech.visualisertest/com.alexpech.visualisertest.VisualiserActivity}: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3
at android.media.audiofx.Visualizer.<init>(Visualizer.java:218)
at com.alexpech.visualisertest.VisualiserActivity.setupVisualiserFxAndUI(VisualiserActivity.java:129)
at com.alexpech.visualisertest.VisualiserActivity.initAudio(VisualiserActivity.java:123)
at com.alexpech.visualisertest.VisualiserActivity.onCreate(VisualiserActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)