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

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

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

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 

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

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

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

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 

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 

Click on Picture for Better Resolution

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

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  

26 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

  14. WOW It works! Thank you for demonstarting. I am using HyperV windows 10 to run linux Ubuntu 22.04 jammy jelllyfish , even though i had use this link to setup “Enhanced Session” (xrdp) , it had no audio.

    Your guidance works! Thanks for clarifying that newer Ubuntu 22.04 support “meson” and no longer uses “build”

  15. @Douglas,

    Thank you for visiting our blog and providing feedback. We area always happy to see that our modest contribution can help other people 🙂
    Please note that we have some additional posts you might be interested in and you might want to give it a try….
    we have developed a small script that can ease the installation of xrdp and enable sound rediretion as well (see xRDP – Easy install xRDP on Ubuntu 18.04,20.04,22.04,22.10 (Script Version 1.4.4) )
    If you are working with Hyper-V and Ubuntu VM, you might want to have a look at this post as well (see xRDP – Hyper-v Enhanced mode for Ubuntu through xRDP software – Revisited)

    Till next time
    See ya

  16. Hi, i am running a ubuntu base distribution: linux lite 6.4 in a vm trying to get audio redirection working with remote desktip. update distro an ran script, getting error: “** Current distro ‘jammy’ does not appear to be supported by debootstrap, Need –suite switch?”
    any assistance would be appreciated.

  17. @Roan,

    Thank you for visiting our blog and providing some feedback and sharing your findings… The script has never been tested with Linux Lite distribution… So, if we have some free time, we could try to have a quick look on it but cannot guarantee you that we will do in the coming days and that we will be able to find a solution.. If you can be a little bit patient, we will have a look into this one…

    Till next time
    See ya

  18. @Roan,

    So we have tested our script against Linux Lite and it works correctly. Using the script, xrdp-installer-1.4.7.sh, you will be able to perform the installation of xrdp package and enable sound redirection in an easy way.
    Since the script is not supporting the Linux Lite Operating system, you will need to open the script and comment the line 1188 (from check_os to #check_os) in order to bypass the check on supported OS vesion.
    You can find all the necessary information on the following post https://c-nergy.be/blog/?p=18918
    Hope this help
    Till next time
    See ya

  19. Just upgraded to Debian Bookworm. I had to add:
    $schroot -u root — apt-get update

    Just above.
    # Install extra dependencies
    $schroot -u root — apt-get install -y $WRAPPED_SCRIPT_DEPS

    Otherwise the apt-get would say the packages were not found.

  20. @Rodney

    Thank you for visiting our blog and sharing your findings… We had no time to play around with Debian 12 yet… But the info provided is a good hint for us… we will look into this and try to update the script accordingly
    Till next time
    See ya

  21. Thanks for providing this great script!
    I am running LMDE6 (Linux Mint Debian Edition). I was running the script with”–suite bookworm” as LMDE6 is based on it. Unfortunately the script quits with the following errors in “pa-build-xyz-schroot.log”,

    Reading package lists…
    Reading package lists…
    Building dependency tree…
    E: Unable to locate package sudo
    E: Unable to locate package lsb-release
    /bin/sh: 1: cannot create /etc/sudoers.d/nopasswd-mbraun: Directory nonexistent
    chmod: cannot access ‘/etc/sudoers.d/nopasswd-mbraun’: No such file or directory
    /build/wrapped_script: 55: lsb_release: not found
    /build/wrapped_script: 55: lsb_release: not found

    Any tips what I can do?
    cheers & thanks!

  22. @Mabraton,
    Thank you for visiting our blog and providing some feedback. Sorry for the late answer… So, if you are using LMDE6 which is based on Debian Bookworm, it means that the default Sound server is not PulseAudio but PipeWire. You can quickly check by issuing the following command Pipewire –version or use this more specific command pactl info | grep “Server Name” | cut -d: -f2 – you might need to install the pactl utility ie sudo apt-get install pulseaudio-utils.

    Since the sound server is PipeWire, you cannot use this version of the script/code/instructions. You will need to have a look at the following instructions see xRDP – Testing Initial Pipewire Sound Rediretion Support in Ubuntu 22.10 (Early Stage). This instructions will be superseeded soon and a new post will be providing necessary information on how to have sound redicrection working on Debian 12

    Hope this help
    till next time
    See ya

  23. Hey .. wanted to thank you for this!

    Followed instructions running on my kubuntu jammy installation (with xrdp) running on proxmox hypervisor. Connected to my macbook with microsoft remote desktop.

    After following instructions I can see a xrdp output in my sound device settings and the sound is coming through.
    Appreciate the effort it takes creating and maintaining these blogs.

  24. @Pookieman,

    Thank you for visiting our blog and sharing your positive experience with the post published … Happy to see that the solution provided is working and can help people out there

    Till next time
    See ya

  25. Error: “You must put some ‘deb-src’ URIs in your sources.list”
    Context : running scripts/install_pulseaudio_sources_apt_wrapper.sh
    Step : running RunWrappedScript /build/wrapped_script -d /build/$PULSE_DIRNAME
    Symptom : /chrootdir/etc/apt/sources.list has becomed empty
    Reason : my sources.list says “stable” dist instead of “bookworm” dist

  26. @Tibolpol,

    Thank you for visiting our blog and sharing your experience. Please note that the latest version of xrdp-installer script could be used to perform your installation on Debian Distributions. Based on your message, it seems that you are using Debian 12. So, first question what’s the default sound server installed on your distribution (PulseAudio or Pipewire).. You can see that by issuing the following command pactl info. if you are using Pipewire, you cannot use this procedure, if you are using Pulseaudio, you simply need to add source repo in your system.

    Hope this help
    Till next time
    see ya

Leave a Reply