Skip to content

Commit

Permalink
Avoid using ALSA when running on WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Dec 8, 2023
1 parent 9fdc04d commit 31650b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion platforms/audio-shared/Sound_Queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Sound_Queue::Sound_Queue()
sync_output = true;

std::string platform = SDL_GetPlatform();
if (platform == "Linux")
if ((platform == "Linux") && (!running_in_wsl()))
{
SDL_InitSubSystem(SDL_INIT_AUDIO);
SDL_AudioInit("alsa");
Expand Down Expand Up @@ -173,3 +173,15 @@ void Sound_Queue::fill_buffer_( void* user_data, Uint8* out, int count )
((Sound_Queue*) user_data)->fill_buffer( out, count );
}

bool Sound_Queue::running_in_wsl()
{
FILE *file;

if ((file = fopen("/proc/sys/fs/binfmt_misc/WSLInterop", "r")))
{
fclose(file);
return true;
}

return false;
}
1 change: 1 addition & 0 deletions platforms/audio-shared/Sound_Queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Sound_Queue {
sample_t* buf( int index );
void fill_buffer( Uint8*, int );
static void fill_buffer_( void*, Uint8*, int );
bool running_in_wsl();
};

#endif
Expand Down

0 comments on commit 31650b8

Please sign in to comment.