AudioFlinger could not create track, status: -12; Error creating AudioTrack

前端 未结 7 1834
花落未央
花落未央 2020-12-24 14:27

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         


        
7条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 15:02

    I was facing this error too recently. Mine was a collision actually taking place multiple times in a loop so it would actually stack the sounds until they dropped out, this causing the error, yet it would keep playing. I fixed this by registering a bounce as 1 when it occurs.

     // bouncecount=
     // 0=no bounce
     // 1=set when bounce occurs and plays the sound
     // 21=reset
    

    Since the game runs at roughly 60fps, this only allows one instance of the sound 3 times a second and could be adjusted easily by changing the 20. Not only did this reduce jitter in the game, it isn't the least bit noticeable.

    if(bouncecount==1){
       sounds.play(sbump,1,1, 0, 0, 1);bouncecount++;}
    else{if(bouncecount<20&&bouncecount!=0){bouncecount++;}
         else{bouncecount=0;}}
    

    Hope this helps someone.

提交回复
热议问题