Skip to content

Commit

Permalink
On Windows 10+, default to WASAPI backend
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Sep 15, 2023
1 parent 6048041 commit c27ce9f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/FAudio_platform_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,36 @@ static void FAudio_INTERNAL_MixCallback(void *userdata, Uint8 *stream, int len)
static void FAudio_INTERNAL_PrioritizeDirectSound()
{
int numdrivers, i, wasapi, directsound;
void *dll, *proc;

if (SDL_GetHint("SDL_AUDIODRIVER") != NULL)
{
/* Already forced to something, ignore */
return;
}

/* Windows 10+ decided to break version detection, so instead of doing
* it the right way we have to do something dumb like search for an
* export that's only in Windows 10 or newer.
* -flibit
*/
if (SDL_strcmp(SDL_GetPlatform(), "Windows") != 0)
{
return;
}
dll = SDL_LoadObject("USER32.DLL");
if (dll == NULL)
{
return;
}
proc = SDL_LoadFunction(dll, "SetProcessDpiAwarenessContext");
SDL_UnloadObject(dll); /* We aren't really using this, unload now */
if (proc != NULL)
{
/* OS is new enough to trust WASAPI, bail */
return;
}

/* Check to see if we have both Windows drivers in the list */
numdrivers = SDL_GetNumAudioDrivers();
wasapi = -1;
Expand Down

0 comments on commit c27ce9f

Please sign in to comment.