Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equalizer - Effect library not loaded

I have almost the same issue as where described here, answer in this post doesn't help me, I release my equalizer immediately after setting band levels to it. It works perfect on my 4.0.4 device, it works great on friend's 2.3.5 device, it crashes on a little percent of devices and it doesn't matter which version of android is running on these devices.

So there is error on

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

java.lang.UnsupportedOperationException: Effect library not loaded
        at android.media.audiofx.AudioEffect.<init>(AudioEffect.java:355)
        at android.media.audiofx.Equalizer.<init>(Equalizer.java:149)

I have no idea how to solve this, any suggestions?

like image 899
pavelkorolevxyz Avatar asked Nov 07 '12 18:11

pavelkorolevxyz


2 Answers

Make sure that you reboot the device and test it again with the release() after using the equalizer, it worked for me after 2 days of searching for clues.

like image 199
read Avatar answered Oct 23 '22 16:10

read


From the documentation, you have to call release() on an Equalizer, MediaPlayer, Visualizer, etc for a graceful exit, or you will see this error when restarting the app. The only remedy then is to reboot, as previously mentioned in this thread.

This is where the Android application lifecycle makes things a little difficult, since apps are never supposed to exit (just pause and resume), unless absolutely required by the OS for memory reasons, or a reboot occurs. Your app onDestroy() method is called in both cases.

You can put the release() in onDestroy(), and that would satisfy the Android lifecycle for deployed apps. Your users would not see this error.

In development however there is a problem: IDEs like Eclipse (which is actually a framework for building IDEs, and not meant to be an IDE itself...) will kill the app process instead of sending it a destroy message. This violates the lifecycle and release() is not called.

This is also why you should never call System.exit(). It violates the lifecycle at the risk of ungraceful exits exactly like this.

So your process was exiting ungracefully. Only happens in development, not deployment. One remedy is to not use the device window in eclipse to stop processes. It is not a stop, but a kill.

Eclipse also kills (lifecycle violation) the process ungracefully when you Run an app project while there is already an instance running.

As the doctor said, if it hurts, don't do it: instead use the debugger which sends actual lifecycle messages to the app.

like image 25
Dominic Cerisano Avatar answered Oct 23 '22 15:10

Dominic Cerisano