Skip to content

Instantly share code, notes, and snippets.

@ANRCorleone
Forked from krisalyssa/readme.txt
Last active November 20, 2024 13:49
Show Gist options
  • Save ANRCorleone/39322bd9514607b072adaa36d080d96c to your computer and use it in GitHub Desktop.
Save ANRCorleone/39322bd9514607b072adaa36d080d96c to your computer and use it in GitHub Desktop.
Ubuntu 22.04 + Hyper V + Enhanced Session mode + XRDP PulseAudio
Credits
# https://c-nergy.be/blog/?p=13655
# https://askubuntu.com/questions/844245/how-to-compile-latest-pulseaudio-with-webrtc-in-ubuntu-16-04
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
# https://unix.stackexchange.com/questions/65167/enable-udev-and-speex-support-for-pulseaudio
# https://rudd-o.com/linux-and-free-software/how-to-make-pulseaudio-run-once-at-boot-for-all-your-users
# https://gist.github.com/rkttu/35ecab5604c9ddc356b0af4644d5a226
# Installation and Enhanced session
# follow steps on the post below, I installed Ubuntu 22.04 on a Windows 11 machine
# https://techbloggingfool.com/2020/12/26/deploy-a-linux-vm-on-hyper-v-with-sound-20-04-edition/
# or do these steps below
# Configure ubuntu for enhanced session
# Note - if it asks to reboot and rerun, rerun the install.sh again
wget https://raw.githubusercontent.com/Hinara/linux-vm-tools/ubuntu20-04/ubuntu/20.04/install.sh
chmod +x install.sh
sudo ./install.sh
# Back to windows powershell
Hyper-V\Set-VM -VMName "Your VM Name" -EnhancedSessionTransportType HvSocket
# Audio with some updates
# Install Some PreReqs
sudo apt-get install git libpulse-dev autoconf m4 intltool build-essential dpkg-dev libtool libsndfile1-dev libspeexdsp-dev libudev-dev -y
# Enable source code as downloadable.(can also do this from the gui Settings > About > Software & Updates)
sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
# Pulseaudio. Download pulseaudio source in /tmp directory - Do not forget to enable source repositories
sudo apt build-dep pulseaudio -y
cd /tmp
apt source pulseaudio
# Compile pulseaudio
# go to the pulseaudio folder (pulseaudio-<version.number>) and build it from source,
# what I did is follow what's currently in the README file, on the section HACKING - currently the instructions are these
cd pulseaudio-<version.number>
meson build
meson compile -C build
build/src/daemon/pulseaudio -n -F build/src/daemon/default.pa -p $(pwd)/build/src/
# Create xrdp sound modules
# go back to /tmp folder then clone
cd ..
git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
cd pulseaudio-module-xrdp
# like the pulseaudio source, I followed their docs to get this done
# https://github.com/neutrinolabs/pulseaudio-module-xrdp/wiki/Build-on-Debian-or-Ubuntu
scripts/install_pulseaudio_sources_apt_wrapper.sh
./bootstrap
./configure PULSE_DIR=~/pulseaudio.src
sudo make install
# Restart Ubuntu, then the VM, hopefully it will all work for you as well. If it works...backup that VM, create a checkpoint :D
# Note. I did not use autologin in Ubuntu, I think autologin could cause issues with regards to sound.
# I kinda guessed that from reading here https://github.com/neutrinolabs/pulseaudio-module-xrdp/wiki/README#install
@gabeyww
Copy link

gabeyww commented Jan 5, 2023

Dude... I don't know who you are, but this is the best solution I have found anywhere to this issue. Your explanation above helped me get my sound working after spending hours online and on my own troubleshooting this exact problem -> Hyper-V on Windows 11, Ubuntu Desktop 22.04, no sound. Thank you!!!!

@pj-spoelders
Copy link

pj-spoelders commented Feb 14, 2023

Hi, I used your instructions succesfully! Thank you very much!

The one step I couldn't complete succesfully was the 'Compile pulseaudio' step.
Instead I decided to risk it and just installed pulseaudio using 'apt install pulseaudio'.

The end result was the same, Audio now works on the VM. Putting this out there for those who have a similar problem like me.

@ANRCorleone
Copy link
Author

Hey everyone, I'm happy that this was helpful 😸

@BlairStewart
Copy link

Thank you for writing this! This got me up and running perfect!

@JohnKDay
Copy link

JohnKDay commented Nov 29, 2023

I can confirm on 11/29/2023 that the above script works. But I would change line 23 to be more explicit,
Hyper-V\Set-VM "Ubuntu-Bravo" -EnhancedSessionTransportType HvSocket.
In my case, I also had VMware Powershell modules installed that caused an error without the Hyper-V prefix.
You may get Set-VM : A parameter cannot be found that matches parameter name 'EnhancedSessionTransportType'.
Because the VMware module also contains a Set-VM command.

@smoonlee
Copy link

I never understood why Microsoft never provided something like this for official docs... This is pretty much what I've been looking at for the last 3 years and have found it finally! Nice work dude! - The only change I would make is to move it to a repo and create a shell script for a quicker install :)

@ANRCorleone
Copy link
Author

@JohnKDay I added your suggestion to line 23, thank you!
@smoonlee really appreciate the kind words 😸

@joeytroy
Copy link

joeytroy commented Jan 7, 2024

@ANRCorleone thank you so much for posting this appreciate it! 👍

@Freedom11b
Copy link

@ANRCorleone, You are a Godsend!! I have been struggling for MONTHS trying to get Enhanced Session to work!

@Dennis-Koch
Copy link

@ANRCorleone Oh my god! You are a true geek hero for me, and my list is quite short. Thank you so much it worked like a charm from start to end

@Bouncerman82
Copy link

Bouncerman82 commented Feb 29, 2024

@ANRCorleone It didn't work for me unfortunately

My configuration:

Ubuntu 22.04 with Hyper V + WIN11.

All commands were successful except for the command : build/src/daemon/pulseaudio -n -F build/src/daemon/default.pa -p $(pwd)/build/src/
(see attachments)

E:[pulseaudio] pid.c: Daemon already running.
E:[pulseaudio] main.c: pa_pid_file_create () non riuscita

Suggestions?

thanks!
Screenshot 2024-02-29 181020
Screenshot 2024-02-29 181302

@moe91asd
Copy link

moe91asd commented Mar 7, 2024

@ANRCorleone
Copy link
Author

@Bouncerman82 sorry for the late response, I had notifications off. I haven't used this script for some time now - WSL2 with its gui has been working great for me. I hope the last suggestion worked for you

@Ib01
Copy link

Ib01 commented May 22, 2024

Does not work on 24.04

@idpetrocheilos
Copy link

Does not work on 24.04

For me xrdp and enhanced session worked. I cannot make the pulseaudio work but before upgrading I got a notification by Ubuntu that pulseaudio is not supported.

@Djay86
Copy link

Djay86 commented Nov 20, 2024

what is pulseaudio for? I checked and audio works fine without doing anything {ubuntu 24.04)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment