Search code examples
iphoneopengl-esperformanceavaudioplayerframe-rate

AVAudioPlayer - Drop in Framerate


I have a quick question: I am loading a mp3 file into a NSData object and then I play it using the AVAudioPlayer in my game. Every second or so, the frame rate drops and you can see a stuttering on the screen. It is not a major slowdown, but clearly noticeable and disrupting to the gameplay. Not playing the music track with the AVAudioPlayer shows no slow down at all.

How can I prevent this from happening?

Thank you.

Florian


Solution

  • For future reference, here is the solution:

    Setting the audio session category to kAudioSessionCategory_AmbientSound (to allow for iPod music to play simultaneously) somehow disables MP3 hardware acceleration. Setting the audio category to kAudioSessionCategory_SoloAmbientSound fixes this, but doesn't allow for iPod playback. I do now set the audio session category depending on whether background music is enabled or disabled to allow for simultaneous iPod playback.