diff --git a/platforms/audio-shared/Sound_Queue.cpp b/platforms/audio-shared/Sound_Queue.cpp index 4dd4fb1b..1aaf9270 100644 --- a/platforms/audio-shared/Sound_Queue.cpp +++ b/platforms/audio-shared/Sound_Queue.cpp @@ -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"); @@ -172,3 +172,16 @@ 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; +} diff --git a/platforms/audio-shared/Sound_Queue.h b/platforms/audio-shared/Sound_Queue.h index d7c4230a..bcd0ddf0 100644 --- a/platforms/audio-shared/Sound_Queue.h +++ b/platforms/audio-shared/Sound_Queue.h @@ -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