Issue
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();
Solution
Solution: When try to write some data into AudioTrack stream while is flushing, it stop flushing, so I have to wait while is flushing, I didn't find a way flush in an async way with callback or in a sync way, so I wait for about 100ms, but it isn't the best solution
Answered By - Lorenzo Tinfena
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.