Support programs that output audio to ALSA
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
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.
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
Can confirm this fixed my audio issue in google-chrome.
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 calledpulse. So what we need is to install the plugin by running$ apt install libasound2-pluginsand enable it manually by editing
~/.asoundrcpcm.default pulse ctl.default pulseFinally, 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!
The suggested solution does not work correctly with the latest version of the various softwares / libs / etc.
➜ aplay 8_Channel_ID.wav
ALSA lib conf.c:1245:(parse_value) default is not a string
ALSA lib conf.c:2012:(_snd_config_load_with_include) _toplevel_:2:0:Invalid argument
ALSA lib conf.c:4120:(config_file_open) /home/user/.asoundrc may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:4042:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:4649:(snd_config_update_r) hooks failed, removing configuration
aplay: main:834: audio open error: Invalid argument
Corrected syntax for the .asoundrc is as follows (Source: Asoundrc Docs):
pcm.!default
{
type pulse
}
ctl.!default
{
type pulse
}
The above change gets sound routing properly from alsa to pulse for wslg, however - it appears best I can tell that various applications remain broken. For instance, chromium and firefox both still do not direct sound properly after this change.