Android MediaPlayer makes the game freeze when AudioHardware pcm playback goes into standby "

This is a difficult question:/

I am creating music based on Android a la Audiosurf. It works all right, except for a few seconds before the end of the song (which is played using the usual MediaPlayer), the music stops appetizing, and the entire game (including the user interface) freezes for several seconds.

Each time this happens, I see that "playing AudioHardware pcm audio files goes into standby mode" -error in logcat.

Googling led me to conclude that

  • This may be an HTC Hero issue that cannot be played on the emulator or other devices.
  • this message is usually logged when the HTTP stream is not fast enough for MediaPlayer
  • Android audio sucks at all

Since I decode mp3 using NDK + libmpg123 for sound analysis, I could just simply play the audio (using the very ugly interface between the NDK C code and AudioTrack in Java).

Is there a fix / workaround for this error, or should I go this way? (I have limited time left to complete this project)

I appreciate every hint!

+4
source share
1 answer

You may stop the music when you have buffered all of this in your C code. Since AudioTrack has a delay in this, you may need more time to complete it.

I need more details about your code to help.

0
source

All Articles