15 July, 2020 | keystroke
For the past two days I have been struggling to try and get audio working through my WSL2 install. While there are some posts on it, none offer a step-by-step guide like there is for X forwarding. So this is how I got this silly little thing working.
This should be the 1.1 version from the PulseAudio site. You can also use the compiled 5.0 version from the x2go project which should be much the same, but I haven’t tested this.
Once this is done you can extract it where you want, I extracted mine to C:\Program Files\pulse
.
In the pulse directory, go to etc\pulse\
, here you will need to edit 2 files.
In default.pa
you need to edit line 42 from
load-module module-waveout sink_name=output source_name=input
to
load-module module-waveout sink_name=output source_name=input record=0
and add these commands to the top (or uncomment then edit them):
load-module module-native-protocol-tcp port=4713 auth-ip-acl=172.16.0.0/12
load-module module-esound-protocol-tcp port=4714 auth-ip-acl=172.16.0.0/12
load-module module-waveout
The second file you need to edit here is daemon.conf
, on line 39 and changing the exit idle time like so:
; exit-idle-time = 20
exit-idle-time = -1
Now PulseAudio is configured, to run it you need to just use
.\pulseaudio.exe
or (in my case)
C:\Program` Files\pulse\bin\pulseaudio.exe
Since I assume you’re all smart, you know how to set this to run on startup or make a shortcut to it, same as any other command-line program.
I use Ubuntu with the bash shell, however the concept should be pretty much the same for distros/shells.
Export the IP of the Windows computer into the PULSE_SERVER
variable:
export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');
And now it should work!
If you want this variable to be assigned on the creation of the shell, just add it to your ~/.bashrc
or shell equivalent, like you would with the $DISPLAY
variable for X forwarding.
This was originally written for a Reddit post and may have a better way to do it now with the continued development of WSL, however now I have a place of my own to keep this I am putting it here also.
If you want to leave a comment or share your thoughts, consider emailing me!