Equalizer not always supported, even when api >= 9?

百般思念 提交于 2019-11-27 07:45:56

问题


before enabling equalizer capabilities, I check for api level to make sure it's equal or greater than 9. From the reports I'm getting from my users, it seems that some exceptions are thrown anyway :

the code eq = new Equalizer(0, mp.getAudioSessionId()) can raise :

Caused by: 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)

and the code eq.getBandLevelRange() can raise :

Caused by: java.lang.UnsupportedOperationException: AudioEffect: invalid parameter operation
at android.media.audiofx.AudioEffect.checkStatus(AudioEffect.java:1182)
at android.media.audiofx.Equalizer.getBandLevelRange(Equalizer.java:206)

I don't know if there is a solution, and if not I could just catch those exceptions and disable equalizer, but I need to know what's exactly causing this, so I can inform my users without frustrating them.

thanks for any help


回答1:


I had this same issue, and it was caused by not calling release() on my Equalizer when I was finished with it. Apparently, the native libraries won't allow instantiation of a new AudioEffect if there are too many already in existence.



来源:https://stackoverflow.com/questions/10536170/equalizer-not-always-supported-even-when-api-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!