xRDP – xRDP Sound Redirection on Ubuntu or Debian – The New Way

Hello World, 

We are slowly preparing the next iteration of our xrdp installer script since a new LTS version of Ubuntu (i.e. 22.04) will be released soon.  While working on that, we have noticed that the xrdp maintainers team have introduced some changes in the way we need to build the sound redirection modules.    This change is due to the fact that PulseAudio compilation process has changed.  They are using now the meson technology.   

So, time to test this new process and see if we can include this in the next version of the xrdp-installer script…. Let’s do this ….! 

Overview

As mentioned above, PulseAudio 15.0 and above is using meson technology to build the needed modules and the ./configure approach has been deprecated.  We noticed the issue when we worked on the xrdp-installer script version 1.3 and we adapted (quick and dirty) our code to have it working against Ubuntu 21.10 and later.  When we released the script, xRDP maintainter teams didn’t updated yet their wiki with the new instructions… 

Since then, the xRDP pages have been updated and a more up to date instructions guide has been made available.  The process seems to be simplified since the xRDP team is providing some scripts that can be run against a specific number of Linux Distros that will ease the build process of the necessary modules to enable sound redirection.   This is the perfect moment to test this new procedure and see if there is no drawbacks  

Assumptions

In order to test this new procedure, we are assuming that you have already installed an Ubuntu or Debian machine and you have already installed xRDP software (either manually or using our xrdp script installer).   Your Linux machine is obviously using PulseAudio software (pipewire is not supported as far as we know)

Please note that these instructions are really specific to Debian based Linux Distributions !!!  

Disclaimer 

The script(s)/instructions hereafter are provided AS IS.  Use it at your own risk !!! 

The Building Process – The New Way 

In the past, the building process was a little bit more complicated than the new way.  Indeed, nowadays, xrdp team is providing some scripts that can be used to build the necessary modules…In the next section, we will summarize all the necessary steps needed to build and install these modules and make sound redirection working when using xRDP software solution….  

Assumptions 

To successfully build your modules,  you will need to ensure that 

  • the account used to perform these instructions has  sudo access
  • The scripts provided by xRDP team assume that all the work will be done from the user’s home directory currently logged on the system 

Prerequisites

Some additional tools and packages might be needed in order to build and compile packages.  To ensure that all the necessary tools are available on your system, issue the following command in your favorite Terminal Console

sudo apt install build-essential dpkg-dev libpulse-dev git autoconf libtool

xrdp_sound_redirection_01

Click on Picture for Better Resolution

Download the PulseAudio Modules for xRDP

In this step, we will need to obtain the necessary files from xRDP github web site.   We will download the pulseaudio-module-xrdp files in the User’s home directory by executing the following command in a Terminal Console

cd ~
git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git

xrdp_sound_redirection_08

Click on Picture for Better Resolution

This should be really fast.  When the download is completed,  we can start building up our modules.  As mentioned earlier, the process has been simplified since the xRDP team is providing some easy to use script to perform all the necessary actions… 

Execute the Script provided by xRDP 

So, time to execute the script.  From your Terminal Console,  issue the following command to ensure that you are located in the correct folder !!! 

cd ~/pulseaudio-module-xrdp

xrdp_sound_redirection_09

Click on Picture for Better Resolution

 

From your Terminal Console,  execute the following command 

scripts/install_pulseaudio_sources_apt_wrapper.sh

You might be prompted for a password during the execution of the script 

xrdp_sound_redirection_02

Click on Picture for Better Resolution

When script is finished, please check the last line displayed.. It will tell you if the script ran successfully or if there are any problems or issues.  This line will also specify where the PULSE_DIR location will be.  This information is needed later and this is an important one…

- All done. Configure PA xrdp module with PULSE_DIR=/home/<%user%>/pulseaudio.src

xrdp_sound_redirection_10

Click on Picture for Better Resolution

Build the xrdp pulseaudio module

In your Terminal Console,  it’s time to build our modules by issuing the following command from the folder ~/pulseaudio-module-xrdp

./bootstrap && ./configure PULSE_DIR=~/pulseaudio.src

xrdp_sound_redirection_11

Click on Picture for Better Resolution

Note the PULSE_DIR Parameter to be passed.  The information was made available in the previous step.  If you didn’t change any scripts, the location should be always the user’s home directory

Finally, time to build our xrdp modules by issuing the make command 

make

xrdp_sound_redirection_04

Click on Picture for Better Resolution

The Installation Process 

If everything worked ok till now (no error messages!!!), it’s time to install the modules we have just build.  To install them, this is super simple, we simply need to execute the following command

 sudo make install

This command should place the modules in the correct directory and should copy a script called load_pa_modules.sh by default in /usr/libexec/pulseaudio-module-xrdp location. Finally, the install process will also execute a startup script that will call the load_pa_modules.sh script when the desktop is loaded which is solving the issue described in this post (xRDP – Sound not always working on Ubuntu 19.10 – Quick Fix).   The startup script will be place in most systems under /etc/xdg/autostart folder.  The startup script should be called something like pulseaudio-xrdp.desktop

To confirm that the modules have been properly installed, you can issue the following command 

ls $(pkg-config --variable=modlibexecdir libpulse) | grep xrdp

If the module-xrdp-sink.so and module-xrdp-source.so are listed, this means that the PulseAudio modules have been properly built and installed on your system 

xrdp_sound_redirection_06

Click on Picture for Better Resolution

 

Some Limitations & Issues

The new way of building and installing xrdp pulseaudio module has indeed been simplified.  The process works against Ubuntu and Debian whatever PulseAudio version you are using.  While testing more and more distributions, the convenience scripts are not working against Pop!OS operating system. The script is throwing some errors one related to the missing repository or missing dependencies. You can check errors through the log file generated by the script.  You can see some screenshot of possible errors we got on Pop!OS 

xrdp_sound_redirection_pop_os

Click on Picture for Better Resolution

Detailed information can be retrieved in the log file generated by the script 

xrdp_sound_redirection_pop_os2

Click on Picture for Better Resolution

The other thing we have noticed  is that the installation takes quite a long time using the convenience scripts.  This is really a minor issue but better be aware of this point….

Finally, based on the PulseAudio version your system is using, the sound redirection experience might vary.  Recent PulseAudio version seems to provide a much better sound redirection experience while the system using older version seems to be more prone to stuttering, delays and poor audio quality.  

Final Notes 

This is it for this post !  As you can see, there is indeed some changes coming with the xRDP package and sound redirection.  In our previous version of the script (version 1.3), we already encountered the issue with the sound redirection and we needed to update the code (quick and dirty fix) to make it work on Ubuntu 21.10 which ships with PulseAudio.  The new way of building the xrdp pulseAudio module is rather straightforward but since it does not seems to work with all Linux distributions; we might want to keep “for the moment” our custom code… We will see what would be the best option….  

Till next time 

See ya  

2 thoughts on “xRDP – xRDP Sound Redirection on Ubuntu or Debian – The New Way

  1. Some notes, Debian bookworm recently upgraded from bullseye.

    – `lsb_release -cs` returns “n/a”. I had to create an override in ~/bin that returned a name.

    – I had to add doxygen to WRAPPED_SCRIPT_DEPS in scripts/install_pulseaudio_sources_apt_wrapper.sh

  2. @Tim,

    Thank you for visiting our blog and sharing your findings… Yep, we see that some minor issues have been encountered with this new way of performing the installation. We are trying to work this out but takes times since we are trying to cover more and more Linux flavors

    As mentioned, working on that and hope to release some fixes soon

    Till next time
    See ya

Leave a Reply