VNC and Pulseaudio

0. I often access to my physical display of my PC and listen to the audio played there.
Here is how I achieve it with vnc and pulseaudio on Arch Linux.

1. Get tigervnc. It comes with libvnc.so which can be loaded via Xorg. There are other solutions like x11vnc and x0vncserver,
however they are very slow compared to libvnc.so. With libvnc.so you can even watch 4k youtube videos over 100mbps link.

pacman -S tigervnc

2.Create conf file under /etc/X11/xorg.conf.d/
If you need authenticaton, just run “vncpasswd” and specify password file like below.
If you don’t need one, just set security tyep to None.

vim /etc/X11/xorg.conf.d/10-vnc.conf

Section "Module"
Load "vnc"
EndSection

Section "Screen"
Identifier "Screen0"
# Option "SecurityTypes" "None"
Option "SecurityTypes" "VncAuth"
Option "UserPasswdVerifier" "VncAuth"
Option "PasswordFile" "/root/.vnc/passwd"
EndSection

3. Get pulseaudio, pavucontrol and pasystray.

pacman -S pulseaudio
pacman -S pavucontrol
yaourt pasystray

3. Edit /etc/pulse/default.pa
Uncomment the lines below on a server. I also enable module-native-protocol-tcp for unicasting, which seems to be faster than RTP option.

load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties=”device.description=’RTP Multicast Sink'”
load-module module-rtp-send source=rtp.monitor
load-module module-native-protocol-tcp auth-anonymous=1
#load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;10.0.0.0/24 auth-a
nonymous=1 # For ACL
load-module module-zeroconf-discover

Uncomment the line below on a client.

load-module module-rtp-recv
load-module module-zeroconf-publish

4. Auto-starting.
Pulseaudo should start automatically, however, in my environment, as soon as I set above setting, pulseaudio fails to
start. So I created the script below and set it to be run in xfce4 startup setting.

#!/bin/bash

sleep 10
pulseaudio -D
pasystray &
exit

5. That’s all. You should be able to access to the server via 5900 port.
Audio can be heard on the client by setting sink to RTP multicast on the server.
For unicast, change default server on pasystray. You should also start pasystray by
“PULSE_SERVER “remote server ip address” pasystray &”

Advertisements