Skip to content

Instantly share code, notes, and snippets.

@rkttu
Last active September 12, 2022 20:28
Show Gist options
  • Save rkttu/35ecab5604c9ddc356b0af4644d5a226 to your computer and use it in GitHub Desktop.
Save rkttu/35ecab5604c9ddc356b0af4644d5a226 to your computer and use it in GitHub Desktop.
(Deprecated) Ubuntu 20.04 + WSL 2 + XRDP PulseAudio
# For those of you looking for this GIST: I don't maintain this code anymore. I recommend using WSLg, which is included starting with Windows 11.
# Please refer to https://gist.github.com/CraigCottingham/fad000cc2ec4678203acf62c4ad2ab23 code that forked this GIST.
# Credits
# https://c-nergy.be/blog/?p=13655
# https://askubuntu.com/questions/844245/how-to-compile-latest-pulseaudio-with-webrtc-in-ubuntu-16-04
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
# https://unix.stackexchange.com/questions/65167/enable-udev-and-speex-support-for-pulseaudio
# https://rudd-o.com/linux-and-free-software/how-to-make-pulseaudio-run-once-at-boot-for-all-your-users
# First, you should install XRDP and X11 Desktop Environment first.
# Step 1 - Install Some PreReqs
sudo apt-get install git libpulse-dev autoconf m4 intltool build-essential dpkg-dev libtool libsndfile-dev libspeexdsp-dev libudev-dev -y
# Enable source repo
sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
sudo apt build-dep pulseaudio -y
# Download pulseaudio source in /tmp directory - Do not forget to enable source repositories
cd /tmp
sudo apt source pulseaudio
# Compile
pulsever=$(pulseaudio --version | awk '{print $2}')
cd /tmp/pulseaudio-$pulsever
sudo ./configure --without-caps
# Create xrdp sound modules
sudo git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
cd pulseaudio-module-xrdp
sudo ./bootstrap
sudo ./configure PULSE_DIR="/tmp/pulseaudio-$pulsever"
sudo make
#copy files to correct location (as defined in /etc/xrdp/pulse/default.pa)
cd /tmp/pulseaudio-$pulsever/pulseaudio-module-xrdp/src/.libs
sudo install -t "/var/lib/xrdp-pulseaudio-installer" -D -m 644 *.so
# TODO: Register pulseaudio as a service
# Restart xrdp
sudo service dbus restart
sudo service pulseaudio restart
sudo service xrdp restart
@YahuiWong
Copy link

i followed all the steps

when type

sudo service pulseaudio restart

thats gave me this error

pulseaudio: unrecognized service

is there any problem ?

kindly guid me through to fix this issue

I made the same mistake, have you dealt with it?

@lrNas
Copy link

lrNas commented Feb 3, 2022

You can register pulseaudio as a service using the following:

Put this text in the file /etc/systemd/system/pulseaudio.service:

[Unit]
Description=PulseAudio system server
# DO NOT ADD ConditionUser=!root

[Service]
Type=notify
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
Restart=on-failure

[Install]
WantedBy=multi-user.target

This unit file is a straightforward method that starts PulseAudio and makes sure it is running.

Now enable and start this unit file by running the following commands:
systemctl --system enable --now pulseaudio.service

It should be running now. You can check the status of the service with the command:
systemctl --system status pulseaudio.service

I've get it on https://rudd-o.com/linux-and-free-software/how-to-make-pulseaudio-run-once-at-boot-for-all-your-users, but adapted it for me!

@ng-aman
Copy link

ng-aman commented Mar 18, 2022

This was incredibly helpful! Thank you so much for writing it.

Some notes, based on my experience building this on xubuntu 20.04:

  • Most of these steps don't have to (and probably shouldn't) run under sudo
  • The sudo install -t step didn't seem to work; sudo make install from the plugin's root directory did, though.
  • No reason to put the module source directory underneath the pulseaudio source directory since the pulseaudio directory is being specified anyway (although there's no harm in it either)

Also at least on my machine the dbus and pulseaudio services weren't running as root, and restarting xrdp was all that was necessary to get audio working on future xrdp sessions (since dbus and pulseaudio are started by the user session).

I m stuck here. can you elaborate which directory you made sudo make install. and do we need to copy files? as commented in #copy files to correct location (as defined in /etc/xrdp/pulse/default.pa). lines 36-37-38 need help.

@rkttu
Copy link
Author

rkttu commented Mar 18, 2022

For those of you looking for this GIST: I don't maintain this code anymore. I recommend using WSLg, which is included starting with Windows 11.

Please refer to https://gist.github.com/CraigCottingham/fad000cc2ec4678203acf62c4ad2ab23 code that forked this GIST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment