Android 声音池问题
我在 Android Market 上有一个应用程序,并且一直在使用 SoundPool 类来实现声音效果。我注意到,在 Android API 的所有部分中,这似乎给我带来了最多的问题。例如:
HTC Desire 在播放 WAV 文件时出现问题(这会导致其随机锁定)。使用 .ogg 文件修复此问题
在 Droid 上,如果超出 init setup 调用中的通道数:
mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
听筒将锁定。如果你能想象调试的难度!在我没有的手机上。这需要我的客户提供大量无私的帮助。将“4”更改为“16”解决了该问题。我毫不怀疑,如果同时播放 16 个声音,它仍然会崩溃。值得庆幸的是,这种可能性很低。
- 还在各种设备上随机崩溃。我从一位客户那里收到了一份目录,其中存在与播放声音有关的“堆溢出”错误。
我现在已更改声音管理器以使用 MediaPlayer。目前看来这一切进展顺利。我只是想知道其他开发者是否也遇到过这些问题?
I've got an app on the Android Market and have been using the SoundPool classes for the sound effects. I've noticed that, of all the parts of the Android API, this seems to have caused me the most problems. For example:
HTC Desire has problems playing WAV files (this causes it to lock up randomly). Using .ogg files fixes this
On the Droid, if you exceed the number of channels in the init setup call:
mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
the handset would lock up. If you can imagine the difficulty in debugging that! On a handset I don't own. It required a lot of selfless help from my customers. Changing the '4' to '16' eliminated the problem. I have no doubt that if 16 sounds were played simultaneously it would still crash. Thankfully the chances of that are low.
- Also getting random crashes on various devices. I have got a catlog from one of my customers which has 'Heap overflow' errors pertaining to playing sounds.
I have now changed my sound manager to use MediaPlayer. This seems to be working out fine for now. I am just wondering if any other developers are experiencing these problems?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎 AudioFlinger 在任何给定时间都可以播放高达 1 Mb 的音频。
如果超过此限制,则会发生堆错误。这个猜测是基于我在 AudioFlinger 源代码中找到的一些代码:
还有
其他人更了解情况吗?
It seems AudioFlinger can have up to 1 Mb worth of audio going on at any given time.
The heap errors occur if this limit is exceeded. This guess is based on some code I found in AudioFlinger source code:
And this:
Anyone else better informed?