using cocos2d-x to play sound effect on android bugs

I use cocos2d-x to play sfx on android, however, it usually won’t play for the first time.
I read the remarks form cocos2dsSound.java as:

/*
* Someone reports that, it can not play effect for the
* first time. If you are lucky to meet it. There are two
* ways to resolve it.
* 1. Add some delay here. I don’t know how long it is, so
* I don’t add it here.
* 2. If you use 2.2(API level 8), you can call
* SoundPool.setOnLoadCompleteListener() to play the effect.
* Because the method is supported from 2.2, so I can’t use
* it here.
*/

I have add a timer to playEffect, when it is first call playEffect, it won’t play, it will add the id to another vector I defined:

public int playEffect(String path, boolean isLoop){
Integer soundId = this.mPathSoundIDMap.get(path);

if (soundId != null){
// the sound is preloaded, stop it first

this.mSoundPool.stop(soundId);

// play sound
int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume,
this.mRightVolume, SOUND_PRIORITY, isLoop ? –1 : 0, SOUND_RATE);

// record sound id and stream id map
this.mSoundIdStreamIdMap.put(soundId, streamId);
} else {
// the effect is not prepared
soundId = preloadEffect(path);
if (soundId == INVALID_SOUND_ID){
// can not preload effect
return INVALID_SOUND_ID;
}

syncSoundPool.add(soundId);// this vector is add by myself

I have start a timer and a timertask to handle syncSoundPool as:

mTimer = new Timer();
syncSoundPool = new Vector();
mTimerTask = new TimerTask()
{

@Override
public void run() {
for(int i = 0; i < syncSoundPool.size();i++)
{
int idx = syncSoundPool.get(i);//(int)syncSoundPool.get(i);
Message msg = new Message();
msg.what = idx;
mHandler.sendMessage(msg);
syncSoundPool.remove(i);
}
}
};
also I have create a handler to handle the message to actually playEffect.

however, when I debug it with breakpoint, it works well, when I disable the breakpoint, it won’t play the sfx for the first time, same as before.

any idea?

I think you should preload effect before playing.
Then it will take effect at first time.

yes, that’s my choose at last.
thanks