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  

13 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

  3. Thank you Griffon!

    This works perfectly (and verbatim) on my Ubuntu 22.04 LTS running on Hyper-V on Windows 10 Version 21H2 (OS Build 19044.1766)

  4. @John,
    Thank you for sharing your experience and visiting our blog 🙂 Nice to see that info provided here is useful and that people can benefit from
    Till next time
    See ya

  5. Thank you the blog.

    I had issue running this command in a single go.
    ./bootstrap && ./configure PULSE_DIR=~/pulseaudio.src

    with these errors:
    ./configure: line 2160: config.log: Permission denied
    ./configure: line 2170: config.log: Permission denied

    I tried running one after another like:
    ./bootstrap
    and then
    ./configure PULSE_DIR=~/pulseaudio.src

    It works.

  6. @Ganesh,

    Thank you for visiting our blog and providing feedback. Thank you for sharing your findings.. We didn’t encounter the issue so far but we are also using a different approach in our xrdp-installer script

    Till next time
    See ya

  7. Thanks for this tutorial,
    I tried it under Debian 11 and after “make” i got this error message with aborting the process

    pulseaudio.src/src/pulsecore/module.h:24:10: fatal error: ltdl.h file oder folder are no existing
    24 | #include

    To solve this under Debian I must install following packed
    sudo apt install libltdl-dev

    Now “make” will run without any problems

  8. @Blacky,

    Thank you for visiting our blog and providing feedback. We will check this one and we will update the script accordingly
    Till next time
    see ya

  9. Thanks from me also.
    Ran on Ubuntu 22.04.01 LTS running as a VM on QEMU-KVM. Worded as a dream.

    Powered off after running your install steps, started connected from Windows 10 MSTC.EXE and worked right away.

  10. @Don Scott

    Thank you for visiting our blog and providing feedback on this topic… 🙂 By the way, the xrdp-installer-script 1.4.3 should support Debian OS as well and should also enable sound redirection when using the -s switch
    Till next time
    See ya

  11. It appears to me that work on xrdp pulseaudio module has not caught up with Linux Mint 21 (vanessa). I am attempting to run Mint virtual desktop machines, connecting with remote desktop connection from Windows 10 workstations. Everything is working except the virtual audio device. My VM host is a Synology DS1621xs+.

    I followed this article until the procedure failed at: s/install_pulseaudio_sources_apt_wrapper.sh Please let me know if any prior versions of Linux Mint are know to work. Or, if there is some other obvious error.

    Many thanks…

    usrname@mintDT:~/pulseaudio-module-xrdp$ scripts/install_pulseaudio_sources_apt_wrapper.sh
    ** Current distro ‘vanessa’ does not appear to be supported by debootstrap
    Need –suite switch?
    usrname@mintDT:~/pulseaudio-module-xrdp$

    usrname@mintDT:~/pulseaudio-module-xrdp$ cat /etc/os-release
    NAME=”Linux Mint”
    VERSION=”21 (Vanessa)”
    ID=linuxmint
    ID_LIKE=”ubuntu debian”
    PRETTY_NAME=”Linux Mint 21″
    VERSION_ID=”21″
    HOME_URL=”https://www.linuxmint.com/”
    SUPPORT_URL=”https://forums.linuxmint.com/”
    BUG_REPORT_URL=”http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/”
    PRIVACY_POLICY_URL=”https://www.linuxmint.com/”
    VERSION_CODENAME=vanessa
    UBUNTU_CODENAME=jammy

  12. @Williams,

    You could give a try to our xrdp-installer-1.4.4 script which can ease installation of xrdp and sound redirection on your system (check this link https://c-nergy.be/blog/?p=18436)… if you do not run the script completely, there is a function that would perform the sound redirection using some custom code… You could also try to dig into the script and make an extract of the code you would need to perform compilation on your own machine

    will try to publish our custom code for sound redirection in the future

    hope this help
    Till next time
    See ya

  13. @M. Williams

    Ok
    We have quickly checked the Linux Mint and the Sound redirection. so, the problem is that Linux Mint has a different way to add sources repository. As a quick workaround, you can manually enable them through the Sources Updates > Optional Sources > Enable Sources Code Repositories…. Then run again the script with the -s switch and the sound should be back….

    We will try in the future to update the script to add support for sound redirection

    Hope this help
    Till next time
    See ya

Leave a Reply