Help me please, how 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 error: ERROR/AudioEffect(2393): set(): AudioFlinger could not create effect, status: -22
that was in xml
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
logcat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{blabla}: java.lang.RuntimeException: Cannot initialize 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) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4 at 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)
That is it? and how to fix this error?
When using the Visualizer
on session 0 you need to have MODIFY_AUDIO_SETTINGS
and RECORD_AUDIO
permissions, but I'm guessing that your app has those because otherwise you'd get a PERMISSION_DENIED
error (-1
if I remember correctly).
Status -22 ought to be BAD_VALUE
. It's not entirely clear to me from the information available in the question why this would happen. Perhaps there's more information available in the logcat output in addition to that line you pasted. Potential reasons for why you'd end up with a BAD_VALUE
status would be e.g. that the effect isn't found, or that the effect already has been inserted in the effect chain.
The problem was gone then I test my app on real phone. somthing wrong with emulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With