A coworker has found a way to share audio over network for No Machine in multinode environments, specifically to applications that are executed in remote servers (not the node) through exporting X (like an ssh -X).

Imagine you have the next scenario:

NX Terminal Server –> NX Node –> Your virtual Environment (desktop) –>  Remote App «Call an application from a remote server» (which requires audio enabled) with ssh -X or export the X server variable.

The main documents of No Machine for audio settings are:

https://www.nomachine.com/AR10Q01048

https://www.nomachine.com/AR11P01006

https://www.nomachine.com/AR11P01006

But, those documents do not explain how pulse works, or how you should set it up in order to work with NX.

Setting up Audio with NX

Objectives:

  • Enable each user to run an instance of Pulse in the node
  • Enable the network support for audio in Pulse Server (NX)
  • Export the Pulse variable to the remote X execution so it uses the enabled pulse server instance.

 

Running pulse in the nodes

My coworker designed an script for this purpose:

root@TESTNOMACHINENODE1:~# cat /usr/local/bin/custom_pulseaudio
dir=$HOME/.pulse_server
disp=$(echo $DISPLAY | cut -d":" -f2)
let snd=5000+$disp
sed -i "s/%port%/$snd/g" $PULSE_SCRIPT
echo $HOSTNAME:$snd > $PWD/.pulse_server
/usr/bin/pulseaudio $@ 

This will be called from /usr/NX/etc/node.cfg (in each node must be enabled)

#
# Specify path and name of the command to start PulseAudio server.
#
CommandStartPulseAudio "/usr/local/bin/custom_pulseaudio"

When a user is authenticated it will run an instance of pulse audio in the node.

Enable pulse audio support over network

Inside the product, when you are using a multinode environment you’ll have a sort of embbed pulse server configuration in:

/usr/NX/share/audio/default.pa

In here you can enable several modules like the xkbbell module. But, to enable audio over network you must enable the module-native-protocol-tcp  functionality of pulse server:

### Load several protocols

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
load-module module-native-protocol-tcp auth-anonymous=1 port=%port%

Export the Pulse variable to the remote X

We call an application using ssh, for example (we have keys not using a password):

(Assuming you know which node you’ve landed, i.e: MY_PULSE_SERVERTESTNOMACHINENODE1:7001)

With the DISPLAY variable we export the display of the current user in the node.

ssh -o StrictHostKeyChecking=no $REMOTE_SERVER "export PULSE_SERVER=$MY_PULSE_SERVER; export DISPLAY=$DISPLAY; google-chrome"

as you can see, we are not using ssh -X  (you could) but we are only exporting the DISPLAY variable and the PULSE_SERVER variables.

Pulse audio isn’t required to be installed in the destination server.