Visualizer exception (audio effects) for Android on Ice Cream Sandwich

In the AudioFxDemo.java sample supplied with the SDK, I get

java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4 

when trying to create android.media.audiofx.Visualizer file

 mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId()); 

(AudioFxDemo.java:173).

As far as I can see, the error arises from the native code (lines 266 ff.) The error also occurs when trying to create the android.media.audiofx.Equalizer file:

 mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId()); 

(AudioFxDemo.java:98)

I get

 java.lang.IllegalArgumentException: Effect type: 0bed4300-ddd6-11db-8f34-0002a5d5c51b not supported. 

I declared the following permissions for my project:

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

Any ideas what might be wrong here?

There seems to be a problem with the API level. I have no problem with Gingerbread (API Level 10). I tested only on virtual devices.

+4
source share
2 answers

This seems to be a problem with the emulator. I tested on a real device running Android 4.0.3, and it worked fine.

+4
source

It seems to be a problem on some Android devices. I got this crash http://pastebin.com/7kqPbxkV in version 1.5 for Lenovo a369i SDK. So far, what I just found is to check if the equalizer effect on the device is supported:

 boolean supports_equalizer=false; AudioEffect.Descriptor [] effects = Equalizer.queryEffects(); for (AudioEffect.Descriptor lDescriptor:effects){ if (Build.VERSION.SDK_INT>=18) { //Equalizer present only starting with API 18. Cam try to hardcode its UUID if (AudioEffect.EFFECT_TYPE_EQUALIZER.equals(lDescriptor.uuid)){ supports_equalizer=true; } } } 
+2
source

Source: https://habr.com/ru/post/1384101/


All Articles