microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.24k stars 307 forks source link

Support programs that output audio to ALSA #864

Open TonalidadeHidrica opened 2 years ago

TonalidadeHidrica commented 2 years ago

Is your feature request related to a problem:

Some programs that make sound talk directly to ALSA instead of PulseAudio. WSLg supports PulseAudio but not ALSA. As a result, we cannot hear audio from such an application.

Describe the solution you'd like:

There is a plugin of libasound2 (ALSA library) that transfers a connection to ALSA onto PulseAudio. The plugin is called pulse. So what we need is to install the plugin by running

$ apt install libasound2-plugins

and enable it manually by editing ~/.asoundrc

pcm.default pulse
ctl.default pulse

Finally, restart the WSL system.

I think this should be the default configuration so that you can use such ill-behaved programs out-of-box.

Describe alternatives you've considered:

Alternatively, we can let users perform those steps manually, at least now that we do have a description here...

Additional context:

No response

Gerdya commented 2 years ago

I would not classify these programs as ill-behaved. For example Chromium always using ALSA. You are only getting sound with Chromium via above described method. In conclusion, I do support your idea.

arbipher commented 1 year ago

Can it be extended to solve the problem due to the missing of /dev/snd/seq?

I saw similar error in random programs e.g. mame or aconnect -o

ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
can't open sequencer
DKingAlpha commented 1 year ago

Can confirm this fixed my audio issue in google-chrome.

selrahc13 commented 1 year ago

Is your feature request related to a problem:

Some programs that make sound talk directly to ALSA instead of PulseAudio. WSLg supports PulseAudio but not ALSA. As a result, we cannot hear audio from such an application.

Describe the solution you'd like:

There is a plugin of libasound2 (ALSA library) that transfers a connection to ALSA onto PulseAudio. The plugin is called pulse. So what we need is to install the plugin by running

$ apt install libasound2-plugins

and enable it manually by editing ~/.asoundrc

pcm.default pulse
ctl.default pulse

Finally, restart the WSL system.

I think this should be the default configuration so that you can use such ill-behaved programs out-of-box.

Describe alternatives you've considered:

Alternatively, we can let users perform those steps manually, at least now that we do have a description here...

Additional context:

No response

This exactly solved my problem with getting Alsa sound working in a Docker image on WSL2. Thank you!