开发者

Android MediaPlayer causes game to freeze with "AudioHardware pcm playback is going to standby"

开发者 https://www.devze.com 2023-01-27 09:38 出处:网络
This is a tough one :/ I\'m making a music-based Android game a la Audiosurf. It works all nice except a few seconds before end of a song (that is being played with a normal MediaPlayer) the music st

This is a tough one :/

I'm making a music-based Android game a la Audiosurf. It works all nice except a few seconds before end of a song (that is being played with a normal MediaPlayer) the music stops aprubtly and the whole game (including UI) freezes for several seconds.

Each time that happens I see an "AudioHardware pcm playback is going to standby"-error in logcat.

Googling has led me to the conclusion that

  • this could be a HTC Hero specifi开发者_JAVA技巧c issue (cannot be reproduced on emulator or other devices)
  • this message is normally logged when a http stream isn't fast enough for MediaPlayer
  • Audio in Android sucks in general

As I am decoding the mp3 with the NDK + libmpg123 for audio analysis already I might aswell just play the audio myself (using a very ugly interface between NDK C code and an AudioTrack in Java).

Is there a fix/workaround for this bug or should I really go that way? (I only have limited time left to complete this project)

I appreciate every hint!


You might be stopping the music when you've buffered it all in your C code. Since the AudioTrack has a delay in it, you may need to wait longer for it to finish.

I'd need more detail about your code to help, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消