This project has moved and is read-only. For the latest updates, please go here.

StreamLatency of Audio Device is Zero

Jan 26, 2016 at 12:15 AM
Hi all,

I've created a big project using NAudio to handle VoiceOutput. So i created a WasapiOut instance for playing my Audiodata to the device. I set a latency Value of 20ms for reading my BufferedVoice Data. So all works fine.

Now quite accidentally I noticed a CPU load over 25%. Now I downladed the NAudio Source Code and added it to my Project. Now I saw that my latency Value I have given to the WasapiOut class is overwriten in the Init method with the StreamLatency Value of the audioClient.
But the StreamLatency in my case is 0. So there will be an endless loop querying the VoiceBuffer for new Data to playout. So I changed the line from
latencyMilliseconds = (int)(audioClient.StreamLatency / 10000);
if (audioClient.StreamLatency > 0)
        latencyMilliseconds = (int)(audioClient.StreamLatency / 10000);
and everything works fine.
But I would like to know why this happens and if my approach is the correct way to resolve the issue. Did you ever had a StreamLatency of 0 with your devices. (It's a common USB Headset)

Best regards
Jan 26, 2016 at 12:19 AM
Sorry, you can close it. I didn't noticed that this have been changed already on github.