I am having a problem With SoundPool as it refuses to work with my .ogg files. I am getting this error:
AudioFlinger could not create track, status: -12
Erro
i just had this issue working on my game. I am building it in android native using java. My problem was 2 fold. 1st I used too many channels when creating my soundpool, then I never released the soundpool when the game ended and went to the game over screen. I used onStop method to release both soundpool and audiomanager when the game ended and that fixed the problem for me.
// in GameActivity
@Override
protected void onStop() {
gameView.audioHandler.release();
super.onStop();
}
// in AudioHandler class
public void release() {
soundPool.release(); // this is my SoundPool
battleMusic.release(); // this is my AudioManager
}
Update: The issue still reoccurred after some more testing. However, what finally ended up eliminating the issue completely ended up being a combination of the previous code and then limiting the sound pool to a max stream of 10 and lowering the quality of the sound MP3s used. The issue was primarily occurring when I had 10+ enemies on the screen all firing lasers using the same sound. Per the SoundPool documentation, when the max stream is reached it logically will eliminate old streams. Given that the -12 code signifies that the 1 MB limit of soundpool has been reached, the conclusion I came to was that it was overburdened with sound and thus by setting it to a stream limit of 10 it could never reach that 1 mb limit and have to begin cycling out old streams. It is odd since my sound effects are not that long in duration, but still it reached the limit. I hope this helps someone!I have not had this issue again since reducing the streams.