Here is an answer to my own question in case anybody is interested. The idea is to create a temporary buffer that creates and stores the audio "latency".
First, initialization:
final int mSizeTable = 300;
private byte[][] mTableAudioBuffer = byte[mSizeTable][];
private int mCountAudioBuffer = 0;
...
mAudioTrack.play();
Then, I fill with:
mTableAudioBuffer[mCountAudioBuffer] = buffer.clone();
int ret = 0;
if (mTableAudioBuffer[(mCountAudioBuffer + 1) % mSizeTable] != null)
ret = mAudioTrack.write(mTableAudioBuffer[(mCountAudioBuffer + 1) % mSizeTable], 0, bufsize);
mCountAudioBuffer = (mCountAudioBuffer + 1) % mSizeTable;
return ret;
Obviously, memory-wise, it's not very optimal and can be greedy if you want a large delay.