SimpleAudioEngine and Android

SimpleAudioEngine and Android
0.0 0



I’m porting a Cocos2d game to Cocos2d-x. By the moment everything is perfect except for one thing: Sound effects on android.

I’m using .ogg files for both background and fx. Background music is playing fine, but when the effects only work correctly if one at a time is played. If I try to play 2 or more effects at a time, all sound effects stop playing.

I preload all the effects played at the beginning of the scene (they are 9 in total).

I have tested on a Nexus S, a LG Optimus 2X and a HTC Hero, and the bug is on the 3 devices…

Any help? There’s something I’m doing bad? On iOS (with .mp3 files) it works with no problem.



Ok, I think I’ve found it.
In file, there’s the following sentence:

private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;

I’ve changed its value to a higher amount (I think Android allows up to 32 sounds):

private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 24;

And now it’s working without problems!


I had the same problem, thanks!