均衡器并不总是支持,即使API> = 9?均衡器、并不、GT、API

2023-09-07 03:29:44 作者:踏月寻星河

实现均衡器功能之前,我检查API级别,以确保它是大于或等于9。 从我从我的用户获得的报告,似乎有些异常被抛出不管怎么说:

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 :

在code EQ =新的均衡器(0,mp.getAudioSessionId())可以提高:

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)

和code eq.getBandLevelRange()可以提高:

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.

感谢您的帮助

推荐答案

我有同样的问题,它是由当我完成它没有要求我释放均衡器()引起的。显然,本地库将不允许新AudioEffect的实例,如果有太多的已经存在。

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.