I’m using a native WASAPI exclusive mode application, that outputs a sine tone to a generic USB speaker. When the latency is set to the minimum allowed (3 msecs), the application can connect to the USB speaker and the output audio sounds correct, and the callback is triggered every 3 msecs. The frequency is 44100 Hz, and the buffer size is 132 samples (132 / 44100 = 3ms latency).
However, after a length of time (it could be 15 mins to several hours), the audio starts playing really slowly and sounds distorted. I find that the callback time has changed from 3ms to 9ms, but the buffer size is still 132 samples and the device is still in WASAPI exclusive mode.
This could be related to the generic USB audio driver supplied by Windows, because the bug doesn’t happen when I output to my laptop speakers which use the Realtek driver.
Is this a known issue? I’ve been able to reproduce with a native WASAPI implementation, and have also reproduced using the third party library Juce, when set to WASAPI exclusive mode.
NOTE that I have a sample app to be used to reproduce the issue (WASAPIRenderExclusiveEventDriven.exe) but I can’t upload it here – please let me know how I can send it to you.
Here are some steps for recreating:
– Windows 10
– Application (exe) that runs in WASAPI exclusive mode and can set the buffer size to the minimum allowed e.g. WASAPIRenderExclusiveEventDriven.exe
– USB speakers
Connect some USB speakers that use the standard Windows USB audio driver (you should not have to install any drivers)
Run the application e.g. WASAPIRenderExclusiveEventDriven.exe
When it says “select a render (output) device” – choose the USB speakers
When it says “Select a capture (input) device” – leave it blank and press return
A sine tone should start playing from the USB speakers. Leave the setup running. After several hours (it can be overnight for some laptops), you will find that the audio is not playing correctly and sounds distorted. In this case, the callback time has changed from 3 ms to 9 ms. The only way to recover the audio is to restart the connection.
Thanks for your help,
Read more here: Source link