Question

I'm playing short aiff sounds using the AVAudioPlayer class while doing animations. Unfortunately, every time a sound plays the frame rate of the animation drops. It seems this can be fixed by setting the AVAudioSession category to AVAudioSessionCategorySoloAmbient, but despite having done this, I'm still seeing a lot of frame rate drops.

I'm settings the AVAUdioSession category in the app delegate like this:

NSError *setCategoryError = nil;
BOOL success = [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategorySoloAmbient error: &setCategoryError];

Am I doing something wrong here?

Was it helpful?

Solution

I am assuming your AVAudioPlayer instance is on the main thread. Move the AVAudioPlayer instance to its own thread. Graphics rendering performance will improve as a result.

Your applications audio session singleton should have no, or at most very minimal, effect with respect to your animation issue. (as you pointed out by ensuring it is set to a non-mixable category)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top