I have trouble with my SoundPool in my Android App.
It was working all find until I played around with the parameters in the play() method of my Soundpool. I have set the playback rate to 2f and got this warning:
06-17 19:53:13.359: W/AudioTrack(11526): AUDIO_OUTPUT_FLAG_FAST denied by client
After setting it back again to 1f I got these errors now:
06-17 19:53:13.359: W/AudioTrack(11526): AUDIO_OUTPUT_FLAG_FAST denied by client
06-17 19:53:13.359: E/AudioTrack(11526): AudioFlinger could not create track, status: -12
06-17 19:53:13.359: E/SoundPool(11526): Error creating AudioTrack
It all happens on my Samsung Note 4 with Android L and in Eclipse. On my Samsung s3 it runs ok but on that I didn't install via USB the App while the rate was still set to 2f.
Here's all the necessary Code:
setting up the sound pool
public void setUpSounds()
{
soundPool=new SoundPool(20,AudioManager.STREAM_MUSIC,0);
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener()
{
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,int status)
{
if(sampleId==beepID)
{
if(status==0)
{
beepLoaded=true;
}
}
else if(sampleId==buttonClickID)
{
if(status==0)
{
buttonClickLoaded=true;
}
}
else if(sampleId==menuEnterID)
{
if(status==0)
{
menuEnterLoaded=true;
}
}
else if(sampleId==menuExitID)
{
if(status==0)
{
menuExitLoaded=true;
}
}
}
});
buttonClickID=soundPool.load(this,R.raw.buttonclick, 0);
beepID=soundPool.load(this, R.raw.beep,0);
menuEnterID=soundPool.load(this, R.raw.menuenter,0);
menuExitID=soundPool.load(this, R.raw.menuexit,0);
}
playing the sounds:
/**
* play the menu exit sound
*/
public void playMenuExitSound()
{
if(soundFXOn&&mAct.menuExitLoaded)
{
mAct.soundPool.play(mAct.menuExitID, 0.2f, 0.2f, 0, 0, 1.0f);
}
}
/**
* play the menu entered sound
*/
public void playMenuEnterSound()
{
if(soundFXOn&&mAct.menuEnterLoaded)
{
mAct.soundPool.play(mAct.menuEnterID, 0.2f, 0.2f, 0, 0, 1.0f);
}
}
/**
* plays the button click sound
*/
public void playButtonClick()
{
if(soundFXOn&&mAct.buttonClickLoaded)
{
mAct.soundPool.play(mAct.buttonClickID, 1f, 1f, 0, 0, 1.0f);
}
}
the beep sound inside the thread
if(mView.soundFXOn&&mView.mAct.beepLoaded)
{
mView.mAct.soundPool.play(mView.mAct.beepID, 0.05f, 0.05f, 0, 0, 1);
}
I just dont see what is wrong, it must be sth internally inside my Note that won't play the sound anymore!
Or something in Eclipse is going totally wrong so that it sends false flags or sth like that