Android AudioHardware pcm播放即将进入待机状态
有时,当我的应用程序中发生很多事情并且使用 SoundPool 播放许多声音时,我的应用程序就会完全冻结。查看日志,我看到以下内容: I/AudioHardwareMSM72XX(56):AudioHardware pcm 播放将进入待机状态。
然后我的应用程序必须强制关闭并重新启动。有谁知道可能是什么原因造成的,或者可能的解决方法?我无法在模拟器中重现此问题 - 只能在我的 HTC Hero 上重现,所以我想知道这是否可能是设备特定的错误。
Occasionally when I have a lot going on in my app, and I am playing a number of sounds using SoundPool, my app just completely freezes. Looking at the logs, I see this:
I/AudioHardwareMSM72XX( 56): AudioHardware pcm playback is going to standby.
My app must then be force closed and restarted. Does anyone know what may be causing this, or a possible workaround? I cannot reproduce this in the emulator - only on my HTC Hero, so I am wondering if this may be a device specific bug.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
造成这种情况的可能原因有两个。
原因 1:如果您没有保留对 MediaPlayer 对象的引用,即使它正在播放某些内容,它也可能会被垃圾收集。我在重复计时器中有一些代码可以播放声音,我必须将 MediaPlayer 分配给静态变量以阻止它被垃圾收集,并且声音中途停止的问题消失了。
原因 2:我读到,如果您正在进行流式传输,则可能会给 MediaPlayer 提供过多的数据,从而导致其死机 - 请参阅此讨论线程:/593575">http://www.last.fm/group/Last。 FM+Android/论坛/114391//593575
There are two possible causes of this.
Cause 1: If you don't keep hold of a reference to your MediaPlayer object it can get garbage collected even though it is playing something. I have some code in a repeating timer that plays a sound, I had to assign the MediaPlayer to a static variable to stop it being garbage collected, and the problem of the sound stopping part way through went away.
Cause 2: I've read that if you are streaming it is possible to give the MediaPlayer too much data and it dies - see this discussion thread: /593575">http://www.last.fm/group/Last.fm+Android/forum/114391//593575