how to get audio working for a wsl2 client using pulse audio on windows

in #programming4 months ago

First I want to say this is a partial continuation of the previous blog post about fixing pso2 and if that guide worked and now you have a working setup here is the next part where you get working audio.

First you will need the software from here: https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/

basicly extract the zip to its own directory and open it.

Now we need to make one change to file in etc\pulse\default.pa

open that file in notepad or vscode (dont use Microsoft word or other rich text editors)

look for a line that says #load-module module-native-protocol-tcp replace it with
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.1.0/24 auth-anonymous=1
This line make it so the pulse audio server you start up listens for connections on the network.

save and close that file and now open a powershell box in the bin directory of the extracted zip.

once its open you should be able to run .\pulseaudio.exe --disallow-exit=true to start the server.

before we jump into ubuntu we need the local ip address of the pc so open a new powershell box and enter ipconfig and look for something that says something like 192.168.1.10 or so.

If the ip address is signficantly diffrent then the one i gave for the load module line you may need to close the server and reopen that file and fix it so the ip address is on the same subnet.

now we need to open a ubuntu box (same one from previous blog post) and do some file edits inside of the ubuntu vm so it will find the server.

once that box is open enter sudo nano /etc/pulse/client.conf then enter your password and you should be in some kind of configuration file

look for a ; default-server server line
now press enter and add this filling in the info from the ipconfig command default-server = tcp4:<ip from ipconfig here>

now press Ctrl+x and when it asks to save the changes allow it to.

theretically you should now be able to open the volume control under the speaker icon and see a window like this:

if you do then you can now open firefox and visit youtube and hear any video you click on (just make sure to turn the volume down otherwise you could hurt your ears)