xRDP – How to redirect Sound on Ubuntu 18.04

Hello world,

Here we are again with a new post about xRDP running on top of Ubuntu 18.04.  Today, the post will try to explain how to configure sound redirection within your xRDP session.  This topic is not new and yes sound redirection is supported with the latest build of xRDP.  The process has been explained and described in the xRDP wiki .  Moreover, searching for the most appropriate information, we also found out that Ubuntu 18.04 ship with a script that suppose to perform all the necessary actions needed to integrate sound redirection in xRDP session. 

Based on these information, we have decided to perform the installation and configuration needed to have sound redirection working. This post will describe our journey and findings in order to get the sound redirection working….. 

Let’s have a look…! 

Assumptions & Pre-reqs

Overview

This post will demonstrate how to configure an Ubuntu 18.04 system to use sound redirection when using xRDP remote desktop software solution. Personally, we do not use this feature but because we have receive the request we have decided to take  a look into the installation process and share our findings in this post. Actually, with Ubuntu 18.04, the process should be as simple as executing two commands 

apt install xrdp-pulseaudio-installer
xrdp-build-pulse-modules

As you will see, we have encountered a small issue with this approach…but nothing that can be fixed….. 

Assumptions

This procedure has bee performed using a specific environment.  The following conditions were met when we have performed the installation and configuration activities

  • We have tested the script on Ubuntu 18.04 with the latest patches (at moment of writing)
  • No additional desktop interface has been installed. 
  • We have performed the test on a Virtual Machine running on Virtual box (where sound capabilities were present inside the virtual machine)
  • xRDP software has been already installed on the system (at least version 0.9.5)

Prerequisites

We assume that you have internet connection on the Ubuntu machine.  The internet connection is needed to download the necessary packages that will be installed on your system.

Configuring Sound Redirection Overview

The first installation attempt 

The first things that we have done was to check if the Ubuntu 18.04 system was running the pulseaudio software.  To perform this check, simply type in a Terminal console the following command 

pulseaudio --version

The output should look like the screenshot below.  This means that you have the pulseaudio components installed on your system. 

Click on Picture for Better Resolution

The next step in the installation consist of installing the new xrdp-pulseaudio-installer package from the Ubuntu Repository.  To perform this action, simply issue the following command 

sudo apt-get install xrdp-pulseaudio-installer  -y

Click on Picture for Better Resolution

You might be prompted for a password.  Provide it and proceed to the next step… 

The final step should consist of executing the following script that will basically download the pulseaudio source and compile them in order to generate two files that will be used by xRDP to redirect the sound 

sudo xrdp-build-pulse-modules

Click on Picture for Better Resolution

However; it seems that there is an error in the script as the following message shows up after the script has run : cd cannot open pulseaudio directory (This seems to be a know bug see here)

Click on Picture for Better Resolution

The script is not able to open the pulseaudio directory because the dget command seems to have an issue (see screenshot)

Click on Picture for Better Resolution

So, at this stage, we have not successfully performed our sound redirection configuration…

Our procedure for Sound Redirection 

Because we do not want to change/modify/interfere with the debugging process, instead of updating the xrdp-build-pulse-modules script, we have decided to first perform a manual installation on a Ubuntu 18.04 system.  Later on, we will probably either create a dedicated script that would perform the installation correctly or we would include this process in our famous Std-Install-Xrdp-v0.x.sh script.

Enable Source code repository 

So, the first thing to do in order to have successful installation  would be to enable the source repository.  To enable this via the GUI, search for the Update & Sources applet and click on it 

Click on Picture for Better Resolution

in the Update and Source dialog Box, tick the checkbox next to the Source code

Click on Picture for Better Resolution

You might get prompted for a password.  Provide it and proceed. You should see something like the screenshot below

Click on Picture for Better Resolution

Press on Close button. You will then be see a popup where you have to click on the reload button in order to have the changes updated on your system 

Click on Picture for Better Resolution

Wait for the system to update the source repositories….

Click on Picture for Better Resolution

At this stage we are ready to move forward….. 

Download Pulseaudio source and compile it 

In this step, we will need to download the pulseaudio binaries and compile them.  No installation is needed here.  The compilation will provide the necessary libraries needed by the xRDP sound redirection compilation process.   So, to download the pulseaudio sources, we will issue the following commands 

cd /tmp
sudo apt source pulseaudio 

This will download the pulseaudio package in the /tmp folder.  So, to compile it, we have to go to the /tmp/pulseaudio* directory and execute the following command 

cd /tmp/pulseaudio*
sudo ./configure

Building the Pulseaudio Module

Since we have the necessary pulseaudio source in tmp directory, it’s time to compile them so they can be used by the xRDP software.  To compile them, we will issue the following commands 

cd /usr/src/xrdp-pulseaudio-installer
make PULSE_DIR="/tmp/pulseaudio-11.1"

This will because create two additional module-xrdp*.so files. These files needs to be copied into the correct location so xRDP can perform sound redirection  

Installing the Pulseaudio Module

This is an important one.  As you know, we are focusing on Ubuntu and we have seen a lot of blogs mentioning that the two module files generated above needs to be copied in the following location /usr/lib/pulse-11.1/modules.    This is wrong !!  

These files needs to be copied in the following location  /var/lib/xrdp-pulseaudio-installer.  So, we will run the following command to copy the correct files into the correct location….

install -t "/var/lib/xrdp-pulseaudio-installer" -D -m 644 *.so

Testing  the Pulseaudio Module feature 

If you perform a remote desktop connection to your Ubuntu, go to the Settings Applet and select sound.  As shown in the picture, you should see a beautiful xrdp sink object under sound card.  If you have that, you almost sure that the sound redirection will work on your system.   

Click on Picture for Better Resolution

To test that, you need to ensure that the remote desktop client has been configured accordingly.  If you are using the microsoft mstsc.exe client, ensure that sound redirection is enabled.   To ensure that sound redirection is enabled, click on the show options

Click on Picture for Better Resolution

This will open the detailed view of the mstsc.exe client and you can set more options there….. 

Click on Picture for Better Resolution

In the advanced view, click on the local resources. In the remote Audio section, click on settings button 

Click on Picture for Better Resolution

Ensure that the first option is selected 

Click on Picture for Better Resolution

When remote desktop connection is established, within your xrdp session, try to launch a music application or browse the internet to find some files with sound in it.  If everything is ok, you should get the sound redirected to your computer and enjoy a little bit more the xRDP features….

Final Notes

Voila ! This is it for this post.  Normally, the installation and compilation process to enable sound redirection should be quite straight forward.  However, it’s seems that there is a small bug in the build pulse audio script.  We have decided not to change the existing script and we have moved forward performing a manual installation.  The next step for us would be to integrate this process and information into the Std-Install-xRDP script.  Because this  feature is not really used by a lot of people (at least around me), the sound redirection configuration will be an option in the script.  So, we will re-work the script to add an additional switch to allow the sound redirection configuration 

This is it for today

Till next time 

See ya

 

27 thoughts on “xRDP – How to redirect Sound on Ubuntu 18.04

  1. Thanks, worked with some minor modifications. I now have audio redirection from Ubuntu 18.04 to Windows 10 🙂

    cd /tmp
    sudo apt source pulseaudio
    cd pulseaudio*/
    sudo ./configure
    cd /usr/src/xrdp-pulseaudio-installer
    sudo make PULSE_DIR=”/tmp/pulseaudio-11.1″
    sudo install -t “/var/lib/xrdp-pulseaudio-installer” -D -m 644 *.so

  2. @Francois,

    thank for the visit and the feedback…We are pleased to see that our work can be useful and used by anyone…
    Till next time
    See ya

  3. @Esten Rye,

    Good move… I was about to mark this one as a bug but it s seems that the issue has been already fixed…. We will need to test this one
    Thank for filing a bug 🙂
    See ya

  4. I use Ubuntu 18.04 and following your manual did these settings. But I a still get Dummy Output instead xrdp sink in Settings -> Sound. Which can I give information to you to check reasons why it doesn’t work for me.

    Thanks.

  5. @Oleg,

    Interesting question…. During the installation process, have encountered any issues/error messages ? the files *.so have been created accordingly ? are they located in the correct location…. You usually need to reboot the system at least one time to make the changes appearing…. Have configured your remote desktop client to redirect sound ?
    Check the basic logs for xrdp and see if there is a problem logged

    What’s your configuration ? physical machine or virtual machine ? which virtualization software are you using ?

    Till next time
    See ya

  6. 1)During the installation process, have encountered any issues/error messages ?
    No, mistakes wasn’t
    2) the files *.so have been created accordingly ? are they located in the correct location…
    Yes, in this path i got two files :/var/lib/xrdp-pulseaudio-installer$ ls
    module-xrdp-sink.so module-xrdp-source.so
    3)You usually need to reboot the system at least one time to make the changes appearing…
    Yes, i did it more one times
    4)Have configured your remote desktop client to redirect sound ?
    Yes, and I also think I can check Dummy Output instead xrdp sink in Settings -> Sound
    5)What’s your configuration ? physical machine or virtual machine ?
    physical machine

    Thanks.

  7. The sound still doesn’t work at 18.04, can we continue to figure out what the cause of the error is, thank you. Please see question above.

  8. @Oleg,

    as far as we know sound redirection should be working on Ubuntu 18.04. are you using one of our installation scripts (custom or Std) ?
    How do you perform xRDP installation ? are you using the standard package from Ubuntu repository ?
    After executing the scripts or the commands listed on this post, you have to shutdown the machine completely (no reboot but a proper shutdown). Reboot the system
    To test sound, go to youtube and start a video and wait at least 1 min before concluding that sound redirection is not working… You can also check the sound settings and check if the xrdp sink object is created

    Hope this help
    Till next time
    See ya

  9. I used the newest Custom Install Script – Version 3.0.
    And it works fine.
    Thanks.

  10. @Oleg,

    thanks for the feedback and the visit… Good to hear that we didn’t mess too much with version 3.0

    Till next time
    See ya

  11. @Robert,

    Thank you for your visit and positive feedback. We happy to see that info can be useful and can help people out there.
    Till next time
    Stay safe
    See ya

  12. @Tobias;

    Ah; always good to know that recipe are still working 🙂
    Enjoy our xRDP + sound and thank you for the visit and providing positive feedback
    Till next time
    See ya

  13. Hello,
    Despitte of the fact that I have Pulse audio 13.99.1 under Ubuntu 20.04.1 i’m blocked at the beginning:
    sudo apt-get install xrdp-pulseaudio-installer
    Lecture des listes de paquets… Fait
    Construction de l’arbre des dépendances
    Lecture des informations d’état… Fait
    Aucune version du paquet xrdp-pulseaudio-installer n’est disponible, mais il existe dans la base
    de données. Cela signifie en général que le paquet est manquant, qu’il est devenu obsolète
    ou qu’il n’est disponible que sur une autre source
    E: Le paquet « xrdp-pulseaudio-installer » n’a pas de version susceptible d’être installée

    Is there a new way to get sound thru Xrdp now 2021 ?
    Thanks

  14. @Loic,

    Thank you for visiting our blog and providing some feedback. Multiple comments

    1/ The post you are referring is to be used with Ubuntu 18.04 and not 20.04.
    2/ Even if the post is a little bit old, there is a section that explain how to perform the installation from sources
    3/ This post xRDP – Missing packages for Sound Redirection in Ubuntu 19.04 was informing you that the xrdp-pulseaudio-installer package does not seems to be maintained anymore. it also explains how to perform the installation and compile from sources
    4/ Finally, we have released a script (xrdp-installer-xx.sh) which should ease your xrdp installation and post configuration….
    Please review the following post xRDP – Easy install xRDP on Ubuntu 16.04,18.04,20.04,20.10 (Script Version 1.2.2)
    The script will help you performing a simple installation and will perform the necessary steps to enable sound redirection as well (you need to pass correct switch – so please read the full post)

    Hope this help
    Till next time
    See ya

  15. @Loic,
    No Problemo…let’s us know if the info was relevant and if you suceeded with your installation

    Till next time
    See ya

  16. @Griffon
    Hi,
    I’ve just read your very complete installation post :
    – As I’m already using standard xRDP configuration since months, I’m just wondering if I have to remove my current configuration (backup it first, how if necessary ?) before proceeding. I’ve seen that your recommend it if we want to add some custom part from your script, I’m interested by sound and login customs
    – I’m wondering also if we need to perform pulseaudio -k each time we connect thru xRDP as I’m in 20.04 or create an automatic launch of this command.
    Thanks

  17. @Loic,

    Thank you for visiting our blog and providing feedback….
    If you are running Ubuntu 20.04, and you have already installed xRDP, you do not need to backup your configuration as redirecting sound is basically adding two additional modules files that you need to create

    Option 1 – To compile from source, please use the info provided at this location https://c-nergy.be/blog/?p=13655 – Section “New Approach compiling from Source”

    Option 2 – If you are running Ubuntu 20.04 version, you can also try to use our xrdp-installer script. The script should be running and perform post configuration actions even if you already have xrdp installed. IF you have used the package provided by Ubuntu; you have to perform a standard installation with the script. Result would depends on customization and modification you have performed on your own xrdp installation. So before using our script, we would recommend either to test it on virtual machine replicating exactly your settings and/or perform a backup of your computer so you can revert back in case of problems

    Th latest version of the script is version 1.2.2 and you can find how to use instructions on this post (https://c-nergy.be/blog/?p=15978)

    A new version of the script is about to be released in 10-15 days which will basically fix the pulseaudio issue… :). Even if you run version 1.2.2 or if you perform the manual install, we can provide you the fix for the sound service to start automatically when performing your remote connection

    So, you have plenty of options…. Up to you to choose what would best fit your needs…
    Hope this help
    Till next time
    See ya

  18. @Andrew,

    Thank you for visiting our blog and providing positive feedback. We are always happy to see that the information provided here is helpful to other
    Till next time
    See ya

Leave a Reply