My game has a couple of different simultaneous QSoundEffects
(mainly gun sounds) and I play them simply like this:
effect.setVolume(0.5f);
effect.play();
The sound data has been loaded beforehand when the application initializes.
On my Ubuntu
desktop this works perfectly, but on Android
some of the sounds don't play. The problematic sounds can be different each time until I restart the app.
What could possibly cause this?
Answer to self:
It seems that there's a maximum count for simultaneous QSoundEffects
. This was expected, but it seems to work so that only the first N sound effects are playing in the order of their creation. The rest are just ignored. It doesn't help anything if you first stop some other sounds that are playing. This makes me believe that the QSoundEffects
are permanently mapped to free audio streams.
I tried to set some of the sources on-the-fly when needed, but it was unstable and PulseAudio
crashed randomly. So...now it seems that I'll take the OpenAL Soft
route as it's easy to compile for Android
.