bogerchan / Nier-Visualizer

A lightweight and efficient Android visual library.
Apache License 2.0
576 stars 75 forks source link

Cannot initialize Visualizer engine, error: -3 #40

Closed azoksky closed 3 years ago

azoksky commented 3 years ago

Hi. Thanks for this amazing Visualizer. In the past it worked for me. But for my new app, I am not sure why it happens. I provided a valid audio session ID but still it gives this error. I am on Android 10.

Here is the code

NierVisualizerManager visualizerManager = new NierVisualizerManager(); visualizerManager.init(audioTrack.getAudioSessionId());//this is valid ID. I checked visualizerManager.start(binding.surfaceView, new IRenderer[]{new ColumnarType1Renderer()});

2021-01-27 17:19:20.868 6620-6620/com.x_bytes E/AudioEffect: set(): AudioFlinger could not create effect e46b26a0-dddd-11db-8afd-0002a5d5c51b / `x��}, status: -1 2021-01-27 17:19:20.868 6620-6620/com.x_bytes E/visualizers-JNI: Visualizer initCheck failed -3 2021-01-27 17:19:20.868 6620-6620/com.x_bytes E/Visualizer-JAVA: Error code -3 when initializing Visualizer. 2021-01-27 17:19:20.869 6620-6620/com.x_bytes D/AndroidRuntime: Shutting down VM 2021-01-27 17:19:20.872 6620-6620/com.x_bytes E/AndroidRuntime: FATAL EXCEPTION: main Process: com.x_bytes, PID: 6620 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x_bytes/com.x_bytes.ModernAudio}: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925) Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.media.audiofx.Visualizer.(Visualizer.java:257) at me.bogerchan.niervisualizer.NierVisualizerManager.init(NierVisualizerManager.kt:42) at com.x_bytes.ModernAudio.onCreate(ModernAudio.java:82) at android.app.Activity.performCreate(Activity.java:7824) at android.app.Activity.performCreate(Activity.java:7813) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:214)  at android.app.ActivityThread.main(ActivityThread.java:7356)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925) 

azoksky commented 3 years ago

I am sorry it worked now.. There was an issue with sample rate of AudioTrack. It's fixed now. Thank you.