AudioTrack.Flush doesn't finish his work, I found out that while AudioTrack is flushing (in an other thread), if I write some data, it stop flush, so I tried to lock AudioTrack while is flushing (no changes), so I tried to ignore the writing of data while AudioTrack is flushing with a simple sleep of 100ms and it works, I suppose that AudioTrack.Flush create a new Thread that flush the buffer, but somebody can explain me this (for me) strange behaviour? P.S. data to write in the buffer has lenght one sample and is spammed (from UDP dgrams) P.s: audioTrack = new AudioTrack(Android.Media.Stream.Music, 16000, ChannelOut.Mono, Android.Media.Encoding.Pcm16bit, 8, AudioTrackMode.Stream, 0);
new Thread(() =>
{
while(true)
{
Thread.Sleep(2000);
canwrite_to_buffer = false;
audioTrack.Flush();
Thread.Sleep(100);
canwrite_to_buffer = true;
}
}).Start();