xRDP – Explaining Sound Redirection issue in Ubuntu 22.04

  The xrdp-installer-1.4.2 fixes the sound Redirection Issue. Check What’s new on version 1.4.2 

Hello World, 

Recently, we have published the latest version of our xrdp-installer script which is set to version 1.4.2.  This version of the script should fix the sound redirection issue that has been detecting in previous versions.   

In this post, we want to provide some quick and dirty information on how to diagnose and fix sound redirection in case you have been using one of the previous version of the script (i.e. xrdp-installer-1.4 or xrdp-installer-1.4.1) 

Let’ move on…. 

Overview 

The Scenario 

Let’s assume that you have used our xrdp-installer script (version 1.4 or 1.4.1) and you have specified the sound switch option.  After running the script,  you would expect that the sound redirection will be working when performing your remote desktop connection.   However, the sound redirection is not working and the settings in the Sound Applet pages does not show the expected settings… 

Case 1 – After running the script, you didn’t reboot the machine where xRDP is installed

If you have performed the xRDP installation, logged out and have not performed the reboot on the machine, you will be able to perform the remote connection.  Within your remote session, you open Settings > Sounds and you will see that the input device is empty and output device is set to dummy (screenshot below)

Click on Picture for Better Resolution

If you try to apply the workaround we have provided in order to have the sound redirection working, you would issue the following command in a Terminal Session 

pulseaudio --start

This should restart the PulseAudio daemon and you would expect to see xrdp object in the sound settings page.  However, after running this command, the sound redirection is still not working and no sound settings changes have been noticed

Click on Picture for Better Resolution

If you are in this scenario,  you will need to reboot the computer first in order to proceed with a final fix….So, you have to go to Case 2 

Case 2 – After running the script, you have rebooted the computer where xRDP software is installed !

If you have rebooted the machine after running the script with sound option selected, you will see something like this in the Settings>Sounds page

Click on Picture for Better Resolution

This time no devices are listed as input and output source.  All settings are blank. 

However, this time if you apply the quick and dirty workaround where you simply restart the pulseaudio process by issuing again the command 

pulseaudio --start

You will notice, this time, that the sound input devices will be populated with xrdp objects and sound redirection will work as expected 

Click on Picture for Better Resolution

Again, this is really a quick and dirty workaround and in order to fix it for good, we need to explain what’s happening and what needs to be changed in the system in order to have a permanent fix.

Explaining the Behavior

xRDP sound redirection is relying on PulseAudio Sound Server Software solution.  Since changes have been introduced in the way the Sound Server is being built, we needed to update the code in order to compile the xrdp sound module correctly.  This change in code was performing an unnecessary action (rebuilding PulseAudio Sound Server) which modifies also some configuration files that are use start PulseAudio Daemon accordingly. 

Thanks to our readers (and more specifically Hiero), we have fixed the issue in the xrdp-installer-1.4.2 and the sound redirection should be working as expected. As mentioned above, the script execution was modifying some configuration file used by the PulseAudio Sound Server.  So, to permanently fix the Sound Redirection issue you might have encountered with the previous version of the script, we will need to update these configuration files….

The “permanent” Fix 

If we look at the status of the PulseAudio service (when remotely connected on the system) via the command line 

systemctl --user status pulseaudio

We can see that the service is active and seems to be running but looking a step further we can see that some errors are displayed

Click on Picture for Better Resolution

We need to check the configuration files used by the PulseAudio Sound Server.  Actually, we will need to check 2 files.  These files are 

/usr/lib/systemd/user/pulseaudio.service
/usr/lib/systemd/user/pulseaudio-x11.service 

Update the Pulseaudio.service File

As a first step, we will quickly check which settings are stored in the /usr/lib/systemd/user/pulseaudio.service file.  To do that, we will issue the following command 

cat /usr/lib/systemd/user/pulseaudio.service

You can see the content of the file in the screenshot below 

Click on Picture for Better Resolution

As shown on the screenshot, the file is configured to start a binary from the /tmp folder.  The line with ExecStart has been wrongly modified and we need to set back the correct value.  Now that we know what we need to change, we can edit this file and modify it accordingly. To modify the file, you have to open it with admin rights using the following command 

sudo nano /usr/lib/systemd/user/pulseaudio.service

Go to the ExecStart line and set the value to 

ExecStart =/usr/bin/pulseaudio –daemonize=no –log-target=journal

as shown in the screenshot below

Click on Picture for Better Resolution

 

Update the Pulseaudio-x11.service File

As you can image, we will need to perform the same kind of modification in order to revert back to the original configuration and to fix the sound redirection feature.  

To modify the file, you have to open it with admin rights using the following command 

sudo nano /usr/lib/systemd/user/pulseaudio-x11.service

As you can see on the screenshot, we will need to modify two lines in this file…

Click on Picture for Better Resolution

As you can see, the path is not correct and should not point to /tmp directory.  We will need to update the lines starting with 

  • ExecStart and,
  • ExecStop 

and set the proper value as shown in the screenshot below

Click on Picture for Better Resolution

Test and Validate the Changes 

At this stage, we still need to apply the changes on the system.  You can do this by issuing the following command 

systemctl --user daemon-reload

Click on Picture for Better Resolution

or simply rebooting the computer

Whatever method you will be using, you can go back to the Terminal console and check the status of the PulseAudio Daemon.  You should have a result similar to the one on the screenshot

Click on Picture for Better Resolution

The screenshot shows also that the Settings > Sounds page is now showing the xrdp object as input and output source for audio.   Now, Sound redirection should be working as expected and you do not need to perform any actions each time you remote login to the system.  The sound redirection will work. 

Final Notes

This is it for this post ! 

The aim was to quick explain what caused the sound redirection issue in version 1.4.1 and to provide a fix in case you have been affected by this behavior. However, please do note that this “bug” in the xrdp script has been fixed in the version 1.4.2. Please always use the latest version of the script in order to take advantage of all the new features and bug fixing as well.  The xrdp-installer-1.4.1 has been declared obsolete and we hope that not too many people have encountered the issue.  If this is the case, you have now the permanent fix that can help you restore the sound redirection feature.  

Thank you to all the users that have provided feedback, information, solution, fixes…that helps us improving the script continuously…. Really appreciated !

Till next time 

See ya

4 thoughts on “xRDP – Explaining Sound Redirection issue in Ubuntu 22.04

  1. Hello and thanks for this wonderful script. I do get an unsupported operating system error when I use my cubic created custom image.
    mtiadmin@srvyardmti:~$ lsb_release -sd
    Ubuntu-Server 20.04.4 2022.07.05 (Cubic 2022-07-05 15:32)

    Can you suggest a way around this? I can change the properties of the image but I don’t know exactly what the script is looking for.

    Thanks again

  2. @Daren,

    Thank you for visiting our blog and providing feedback. In your case, the easiest would be to modify the script. Locate the function called check_os()
    The function looks like the extract below

    (..)
    check_os()
    {
    echo
    /bin/echo -e "\e[1;33m |-| Detecting OS version \e[0m"

    case $version in

    *"Ubuntu 18.04"*)
    /bin/echo -e "\e[1;32m |-| OS Version : $version\e[0m"
    /bin/echo -e "\e[1;32m |-| Desktop Version : $DesktopVer\e[0m"
    ;;

    (...)

    Replace the value in bold above *”Ubuntu 18.04″*) with *”Ubuntu-Server”*
    This will allow the script to run and accept your operating system as a possible candidate

    Since I have no clue about your configuration and OS version… Proceed at your own risk.. I would recommend you to perform a test first on a machine to see how far the script will go… We are also assuming that you have a DEsktop interface installed on your machine : )

    Give it a try and provide feedback

    Till next time
    See ya

  3. Hi, Unfortunately, all the steps described lead to a working sound, but on the remote machine (which is directly next to my host windows machine) the sound now is working ( before I only got a useless dummy device), but not on the host.

    I have Ubuntu22.04, I have first uninstalled xrdp (with sudo apt remove –purge xrdp) and then reinstalled using your very actual script v.14.3. After that and reboot the dummy device was repaced by the two possible onboard sound devices of my ASUS G752VSK:
    – Digital Output S/PDIF – Built-in audio (this one is not connected and does not provide a sound)
    – Speakers – Built-in Audio (this works)

    Ther is no “xrdp sound device”. All the scripts changes to the config files were exactly as above described.

    Dou you have maybe any hint, what to prove next??

  4. @Peddanet,

    Thank you for visiting our blog and providing some feedback
    Ok, this one is a though one….but I would guess that compilation didn’t go through (might be missing some dependencies for your system…)

    • Are you sure that the module files compiled accordingly (no errors in the output console when you have run the command).
    • Can you check that the module files for xrdp_sink are there ?

    You could try to use the script provided by xRDP maintainer (please have a look at this post – xRDP – xRDP Sound Redirection on Ubuntu or Debian – The New Way
    You can try to load the module manually and see what’s happening and if they exists and are recognized (inside your remote session)

    pactl load-module module-xrdp-sink
    pactl load-module module-xrdp-source

    hope this help
    Till next time
    See ya

Leave a Reply