How to redirect Pulse-audio over SSH and open up a socket file reverse tunnelled to the local Pulse-audio server on the client.

cmoerz

Active Member

Reaction score: 86
Messages: 175

I feel your pain. I've been in a similar spot before when I tried to get Netflix working via a Linux VM. In the end I went with the Linux emulation layer because it turned out to be less painful.

Having said that, and not knowing your particular use case, let me add something that I did not see mentioned while walking through this thread:
  • you are not seeing any audio input or audio output when connecting via VNC because there is no audio device on the VM; I looked into audio on bhyve and there appears to be some patches but I failed to make them work for me. Still, this probably is not required for your desired setup anyways.
  • There used to be a really good write up on pulseaudio by Colin Guthrie; it appears written up for Linux, but the general message applies to BSD just fine. It appears to be down at the moment. I'm still leaving the URL in the hopes that it'll turn up again eventually: http://colin.guthr.ie/2009/08/sound-on-linux-is-confusing-defuzzing-part-2-pulseaudio/
  • To get audio on xrdp, you will probably need some audio device or plugin. A google search revealed https://github.com/neutrinolabs/pulseaudio-module-xrdp but I can't say whether this really works since I never tried it myself. (that's wrong as shown by other posts)
  • Alternatively, you might also want to check out x11/xpra, which has audio transport built in as well and would allow you to use applications seemlessly. I liken it to a Citrix session though there's quite some technical differences, obviously. Not sure whether this requires a remote audio device, a dummy dev might still do the trick, I suppose.
 

Geezer

Aspiring Daemon

Reaction score: 617
Messages: 937

  • because there is no audio device on the VM; I looked into audio on bhyve

Really? I seem to have sound working on my bhyve (windows 10). I can hear all the system sounds and play music within windows (if I wanted), and whatever else. Sound seems to work in bhyve.
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

Quote
Sound seems to work in bhyve.

Interesting. I must have missed something then. I'm still on 12.2; my bhyve()'s emulation section lists no audio device. I suppose you are seeing a virtual audio device from xrdp and we're likely referring to two different things?

Also, turns out the xrdp plugin is for audio input, not output. Serves me right for attempting to speed read a Github readme. So, that's not right.
Thanks Geezer for following up - made me look twice and gives me a chance to correct my mistake.
 

Geezer

Aspiring Daemon

Reaction score: 617
Messages: 937

1628150562147.png


For your reference:
BHYVE_FLAGS=" \ -c sockets=1,cores=2,threads=2 \ -m 6G \ -H \ -w \ -U whatever-whatever-whatever-whatever \ -s 0,hostbridge \ -s 4,ahci-hd,window.10.pro.64.disk.img \ -s 5,virtio-net,tap0 \ -s 29,fbuf,tcp=0.0.0.0:5900,wait \ -s 30,xhci,tablet \ -s 31,lpc \ -l com1,stdio \ -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \ "

Now on 13.0, used to work on 12.X as well.

1628150882149.png
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

Alright, it's embarrassing. I've been using net/remmina and never realized that my RDP connection had audio disabled. Setting it to local output suddenly makes it work on my end as well. Again, thanks Geezer. Sometimes it takes a nudge to not leave it at "doesn't work for me but I don't need it anyways".

Apologies for kind of hijacking this thread. At least it's a confirmation that RDP audio redirection works quite well... I just tested this with net/xrdp based on FreeBSD. That works just fine too - as long as you consider the audio option of your RDP connection. It's not the same quality as Linux emulation, I'd like to add though...

For reference: in remmina, go to Advanced tab for an RDP connection, set audio output mode to "Local". You'll need net/freerdp installed for RDP to work in remmina, if I remember correctly.
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

Below you can see me connected to the jetson nano through turbo vnc that I'm hearing a song on youtube. I'm using the Unitek usb stick with an audio jack connected to the speakers. If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me.

226605835_10224268628919293_6254840984662515509_n.jpg
 

Geezer

Aspiring Daemon

Reaction score: 617
Messages: 937

Yes cmoerz , easy to overlook but quite useful.

Below you can see me connected to the jetson nano through turbo vnc that I'm hearing a song on youtube. I'm using the Unitek usb stick with an audio jack connected to the speakers. According with your posts,I shouldn't hear anything ?

I don't know what you can hear, but whatever, it is not coming through vnc.
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

I'm hearing a song on youtube

Not sure, if you're referring to my statement or previous posts. Just to clarify: I pointed out the lack of audio emulation in bhyve VMs. That doesn't stop you from using virtual devices as they are offered by RDP.

If you connect to a hardware device with audio capability, playing audio remotely via VNC will certainly still work - as you confirmed. It will however not play back locally on the computer you are running TightVNC on. It will play on the audio jack and audio hardware of the remote device.

Hence, if you connect to a bhyve VM with VNC, you'll only have the audio output option that's in the VM - which is none, because there is no audio emulation. Unless you successfully patch in some audio support. As stated before - that didn't work for me but YMMV.
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

so. If I attach the usb audio stick to the PC where runs Debian emulated with bhyve and I will pass the usb port through bhyve or even the whole USB controller,it will work ? If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me. Anyway,I didn't understand what you are suggesting me to do.
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

View attachment 10894

For your reference:
BHYVE_FLAGS=" \ -c sockets=1,cores=2,threads=2 \ -m 6G \ -H \ -w \ -U whatever-whatever-whatever-whatever \ -s 0,hostbridge \ -s 4,ahci-hd,window.10.pro.64.disk.img \ -s 5,virtio-net,tap0 \ -s 29,fbuf,tcp=0.0.0.0:5900,wait \ -s 30,xhci,tablet \ -s 31,lpc \ -l com1,stdio \ -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \ "

Now on 13.0, used to work on 12.X as well.

View attachment 10895
We are using different OS. So,I should assume that for you it works because you are using Windows and Instead,I'm emulating Debian ? In addition I'm not using bhyve,but vm-bhyve. I still have a problem that no one has been able to help me to fix. This : https://forums.freebsd.org/threads/...ause-the-error-network-unreachable-n-2.81340/
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

so. If I attach the usb audio stick to the PC where runs Debian emulated with bhyve and I will pass the usb port through bhyve or even the whole USB controller,it will work ? If the audio does not come from VNC I don' care so much. If It will work using another method its ok for me. Anyway,I didn't understand what you are suggesting me to do.
Not sure, I believe bhyve does not support USB passthrough. There's PCI passthrough, haven't seen that for USB yet.

You could either use RDP (xrdp/freerdp), which will provide a virtual audio device in your Debian VM that plays back on your RDP client; or you could try forwarding a pulseaudio port via SSH. There appear to be some resources on that matter - I have not tried this myself but know from sharing my portaudio socket with the FreeBSD linux emulation that the technique works quite well. It should work just fine over SSH too.

I'm certain there's other options with sndio or alsa; I'm just highlighting two that I'm confident will lead to a working solution.


 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

Anyway,I can do the passthrough of the whole Nvidia PCI Express 3.0 that has an HDMI / audio connector that I can use.
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

View attachment 10894

For your reference:
BHYVE_FLAGS=" \ -c sockets=1,cores=2,threads=2 \ -m 6G \ -H \ -w \ -U whatever-whatever-whatever-whatever \ -s 0,hostbridge \ -s 4,ahci-hd,window.10.pro.64.disk.img \ -s 5,virtio-net,tap0 \ -s 29,fbuf,tcp=0.0.0.0:5900,wait \ -s 30,xhci,tablet \ -s 31,lpc \ -l com1,stdio \ -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \ "

Now on 13.0, used to work on 12.X as well.

View attachment 10895

can u tell me how you have configured the network interface tap0 and the bridge necessary to make bhyve work ?
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

I read through those logs on Github as well as in your previous posts; you're trying to connect as root. I believe this will not work, unless you updated your /usr/local/etc/xrdp/sesman.ini beforehand (see AllowRootLogin value). I can't tell from the logs whether you already fixed that.

If you don't want to wade through freerdp's man page to set username, password et al, I can highly recommend net/remmina - even though it probably comes with a bunch of gnome related dependencies. So I won't blame you for not wanting that.

Either way, I'd recommend connecting to a user account that already exists on your debian vm, or one you created for remote use.
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

I wanted to know what's your detailed configuration for bhyve regarding the network interface. As I've told,I'm not able to use bhyve,but only vm-bhyve. The problem I have is that if I use bhyve,then the virtual machine is not able to connect to internet. I've tried remmina. It didn't work. You can go here if u want to see the error that I get and that I haven't been able to fix yet : https://www.reddit.com/r/Remmina/comments/ozf73g/cant_startconnect_to_pulseaudio_using_remmina_on/. I know that I have opened this thread to fix the pulse audio problem and its not right to use it to fix another problem,so you can give a look at the thread that I have opened some time ago,where I have explained the problem,that at today hasn't been fixed yet. Here : https://forums.freebsd.org/threads/...or-network-unreachable-n-2.81340/#post-524571
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

I've installed remmina on FreeBSD 13 and the xrdp server on Ubuntu 21.04. This is the guide that I have read :

https://github.com/neutrinolabs/pulseaudio-module-xrdp

the installation and configuration of the modules went good,I didn't see any error. At the end of the guide,he says : "To see if it works, run pavumeter in the xrdp session. Playback any YouTube video in Firefox. You'll see "Showing signal levels of xrdp sink" and volume meter moving.

I've issued some commands on the terminal and I saw that the sound levels are moving. Anyway,I don't hear any sound from youtube videos.

Istantanea_2021-08-09_00-31-19.png
 

Attachments

  • Istantanea_2021-08-09_00-16-25.png
    Istantanea_2021-08-09_00-16-25.png
    17.1 KB · Views: 45

cmoerz

Active Member

Reaction score: 86
Messages: 175

Alright, you're one step further. I see you got the RDP connection working now. The neutrinolabs plugin actually is required only if you intend to do recording in the VM as well. Apologies for that, I mentioned that only in a later post.

Anyways, I suspect that your issue might now lie within your host, not in the vm. For the local playback to work, you'll likely need pulseaudio to run in your host as well. Otherwise, remmina will not be able to play back any sound. Did you already run something like pgrep pulseaudio (or even better: pactl info) to check whether pulseaudio is running?
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

can u satisfy my curiosity ? remmina (or whatever) does need that I run bhyve with the parameter that "take" the audio from the host and that "put" it inside the virtual machine ? I ask this because with qemu the audio should be configured adding some parameters to qemu itself.

anyway : from freebsd host :

Code:
marietto@marietto:~ $  pactl info

Stringa server: /var/run/user/1001/pulse/native
Versione protocollo libreria: 34
Versione protocollo server: 34
Locale: sì
Indice client: 11
Dimensione tile: 65472
Nome utente: marietto
Nome host: marietto
Nome server: pulseaudio
Versione server: 14.2
Specifica di campionamento predefinita: s16le ch 2 44100 Hz
Mappa del canale predefinita: front-left,front-right
Sink predefinito: oss_output.dsp8
Sorgente predefinita: oss_input.dsp8
Cookie: e95d:2589

Infact as u can see,my bhyve config file does not include any audio setting :

Code:
loader="uefi"
cpu=8
memory=8GB
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="ubuntu-budgie-gpu.img"
uuid="ca6be87e-eed2-11eb-abbb-e0d55ee21f22"
network0_mac="58:9c:fc:0a:b1:92"
graphics="yes"
graphics_res="1440x900"
xhci_mouse="yes"
 

cmoerz

Active Member

Reaction score: 86
Messages: 175

Well, in principle, you have some virtual audio emulation in xrdp that plays audio (and with the neutrinolabs plugin supposedly is also able to record) in your debian VM. So, you should actually be running the opposite way - with playback to "Local" on your host, playing back the audio from your guest VM. You would not need any bhyve options for that, because you're not using any emulated audio hardware but the virtual RDP audio channel in the VM.

The pactl output tells me that pulseaudio seems to be fine in your host. If I were you, I'd try without the neutrinoplugin in debian, if that still fails to play.
I suppose, you did confirm before, that local playback (i.e. playing some music via VLC or a Youtube video in Firefox) in your FreeBSD host already works? So I'm assuming that, with the right remmina settings, this has got to work.

In the end, the setup should look something like this:
Code:
freebsd --remina/RDP------> xrdp | debian (bhyve)
     audio playback:
     local
 
OP
ziomario

ziomario

Daemon

Reaction score: 138
Messages: 1,084

maybe I found the reason why it does not work. In the remmina client I should fill the value for "redirect the local audio ouput" but I don't know which value should I put there.

Screenshot_20210811_154910.png
 
Top