AudioFlinger could not create an effect, status: -22

Please help me how to fix this?

public class VisualizerCapture extends Activity implements Visualizer.OnDataCaptureListener private Visualizer mVisualizer; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mVisualizer = new Visualizer(0); setupVisualizer(); private void setupVisualizer() { mVisualizer.setEnabled(false); mVisualizer.setCaptureSize(8); //test mVisualizer.setDataCaptureListener(this,250,false,true); Log.v("ABS","setupVisualizer" + mVisualizer.getEnabled()); //log 

This code throws an error: ERROR / AudioEffect (2393): set (): AudioFlinger could not create an effect, status: -22

which was in xml

  <uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> 

LogCat:

java.lang.RuntimeException: cannot start Activity ComponentInfo {blabla}: java.lang.RuntimeException: cannot initialize the Visualizer engine, error: -4 at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:1956) at android.app. ActivityThread.handleLaunchActivity (ActivityThread.java:1981) at android.app.ActivityThread.access $ 600 (ActivityThread.java:123) at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1147) on android.os.Handler. dispatchMessage (Handler.java:99) on android.os.Looper.loop (Looper.java:137) at android.app.ActivityThread.main (ActivityThread.java:4424) in java.lang.reflect.Method.invokeNative (native method) in java.lang.reflect.Method.invoke (Method.java∗11) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:784) at com.android.internal.os.ZygoteInit .m ain (ZygoteInit.javahaps51) in dalvik.system.NativeStart.main (native method) Called: java.lang.RuntimeException: it was not possible to initialize the Visualizer engine, error: -4 on android.media.audiofx.Visualizer. (Visualizer.java:182) at com.blablabeta.gui.VisualizerCapture.onCreate (EqVisualizerCaptureAudio.java:27) at android.app.Activity.performCreate (Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate (Instrumentation java: 1049) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:1920)

The way it is? and how to fix this error?

+4
source share
2 answers

The problem has disappeared, and I am testing my application on a real phone. something is wrong with the emulator.

+1
source

When using Visualizer in session 0, you need to have MODIFY_AUDIO_SETTINGS and RECORD_AUDIO , but I assume your application has these because otherwise you will get the PERMISSION_DENIED error ( -1 if I remember correctly).

Status -22 must be BAD_VALUE . This is not entirely clear to me from the information available on the question of why this will happen. Perhaps in addition to the line you inserted, the logcat output has more information. Potential reasons why you end up with the status BAD_VALUE will be, for example, that the effect was not found, or that the effect is already inserted into the effect chain.

+3
source

All Articles