Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] SDL2 since 2.0.6: Audio issues because of switch to WASAPI #1405

Ghabry opened this Issue Jul 20, 2018 · 2 comments


None yet
2 participants
Copy link

Ghabry commented Jul 20, 2018

Context: I already use vcpkg+CMake under Windows locally and got reports from the (hardworking bug hunter) "Deep 8 dev" that the audio is broken since a while. The last build I sent him few weeks ago used SDL2 2.0.5 and I just read through some mails and got the confirmation that the audio works again.
[Still on vacation, just opening the issue before I forget it]

SDL2 changed the Audio API under Windows to WASAPI because it has a reduced latency compared to DirectSound or XAudio2.

This appears to result in issues with our Audio Decoders.

There is no regression yet because our official build uses SDL2 2.0.5

The BGM has spurious buffer underruns (crackling noise) and when the Player Window loses/regains focus there is a very short high pitched noise.

Changing the audio format to F32 in our audio decoder doesn't seem to fix the problem (I also can't really reproduce it because the Audio in libvirt is in general broken and full of glitches xD)

[I also got a video for this which allows you to listen to the problem but can't upload it before I'm home again]

Current workaround: Use SDL2 2.0.5 and SDL2 Mixer 2.0.1 until a solution is found.

@Ghabry Ghabry added the Audio label Jul 20, 2018


This comment has been minimized.

Copy link

fdelapena commented Jul 20, 2018

Possibly relevant commit from Hg (in case of SDL2 resampler was related somehow):
"wasapi: let Windows do the resampling for us if possible."
It also might require testing with larger buffer size setting.
Other possibly involved bugs:
"SDL_GetQueuedAudioSize is broken with WASAPI":
Another weird wasapi behaviour:
Another bug report with similar issues (choppy audio):

Note the second comment by icculus and the following with a better workaround we could use here in the meanwhile:

#ifdef _WIN32
SDL_setenv("SDL_AUDIODRIVER", "directsound", 1);

However, this is not the most reliable way, as there are reports about broken Windows not supporting directsound (wtf?). The driver is called dsound in SDL 1.2, though. To make sure this is reliable, and allowing a fallback to winmm in SDL2 enumerating audio drivers and skipping wasapi in the enumeration loop may be an easier way to do this since SDL2 for the Win32 case: (relevant: code example) (relevant: code example, using SDL_Init is still okay).

Test case (not tested on Windows, but should work, too):


#include "SDL.h"
int main() {
    int i;
    for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
        printf("Audio driver %d: %s\n", i, SDL_GetAudioDriver(i));
    return 0;
gcc testaudio.c -o testaudio `pkg-config --cflags --libs sdl2`
$ ./testaudio
Audio driver 0: pulseaudio
Audio driver 1: alsa
Audio driver 2: dsp
Audio driver 3: jack
Audio driver 4: disk
Audio driver 5: dummy

This comment has been minimized.

Copy link
Member Author

Ghabry commented Feb 7, 2019

as of #1572 this should be solved, there were also no reports anymore by the deep 8 dev, therefore I assume later SDL2 versions fixed the audio glitches.

@Ghabry Ghabry closed this Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.