Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef _WIN32
- void disableWasapi(void) // call this function before SDL_Init()
- {
- // disable problematic WASAPI SDL2 audio driver on Windows (causes clicks/pops sometimes...)
- const int32_t numAudioDrivers = SDL_GetNumAudioDrivers();
- if (numAudioDrivers <= 1)
- return;
- // look for directsound and enable it if found
- for (int32_t i = 0; i < numAudioDrivers; i++)
- {
- const char *audioDriver = SDL_GetAudioDriver(i);
- if (audioDriver != NULL && strcmp("directsound", audioDriver) == 0)
- {
- SDL_setenv("SDL_AUDIODRIVER", "directsound", true);
- return;
- }
- }
- // directsound is not available, try winmm
- for (int32_t i = 0; i < numAudioDrivers; i++)
- {
- const char *audioDriver = SDL_GetAudioDriver(i);
- if (audioDriver != NULL && strcmp("winmm", audioDriver) == 0)
- {
- SDL_setenv("SDL_AUDIODRIVER", "winmm", true);
- return;
- }
- }
- // we didn't find directsound or winmm, let's use wasapi after all...
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement