question

KotisiFakalata-3713 avatar image
1 Vote"
KotisiFakalata-3713 asked KotisiFakalata-3713 commented

WASAPI exclusive mode: audio becomes distorted at low buffer sizes

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:
Setup:
- 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

  1. Connect some USB speakers that use the standard Windows USB audio driver (you should not have to install any drivers)

  2. Run the application e.g. WASAPIRenderExclusiveEventDriven.exe

  3. When it says "select a render (output) device" - choose the USB speakers

  4. 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,
Kotisi

windows-hardware-code-audio
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

As a bit of background - originally I was trying to connect to a Pro audio hardware with WASAPI exclusive mode for minimal latency, but started hitting this bug. To rule this out as a hardware specific bug, we started testing with some USB speakers (M1Active 320USB speakers) and were able to reproduce the issue. In both cases, I believe the standard Windows USB audio driver is being used (usbaudio.sys). Thus far we have only reproduced the issue when connected to output devices that use the standard Windows driver.

0 Votes 0 ·

0 Answers