0%

proxy sound application on remote machine

We can use pluse audio to play sound from remote machine over network.

For example, we have a remote server. And we want to play the sound on local machine while playing media file on the server. Here is the solution.

start pulseaudio on machine with audio card

Win10 T470 laptop with sound speaker.

Get pulseaudio binary for windows from official wiki, they provide the pulseaudio mingw version 1.1.

here is another place for building pulseaudio with mingw, binary pulseaudio mingw version 13.0 is provided.
use it with your own consideration.

add configuration in etc\default.pa to enable sound over tcp (acting as server)

  • load-module module-native-protocol-tcp port=4713 auth-ip-acl=0.0.0.0/0
    the acl could be more accurate like 172.17.0.0/12 in CIDR format

here are some other items may be impacted, use them only when above change is NOT enough for working

in etc\default.pa

  • load-module module-waveout sink_name=output source_name=input record=0
  • set-default-sink output

in etc\daemon.conf

  • exit-idle-time = -1

and now we can start pulseaudio by typing bin\pulseaudio -vvvv in cmd or powershell shell

configure client mode on working machine

usually this is the machine where sound card is NOT available. (say virtual machine or Rasperberry PI)

1
2
3
4
$ sudo apt install pulseaudio mpg123 -y
$ mkdir ~/.pulse
$ cp /etc/pulse/client.conf ~/.pulse/.
$ echo "default-server = 10.10.10.1" >> ~/.pulse/client.conf

now we can use mpg123 abc.mp3 to play mp3 file on working machine and listen the voice on our target win10 machine.

debug information

if we run pulseaudio with parameters -vvvv, we can see sample output on server side like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
I: [(null)] pulsecore/client.c: Created 4 "Native client (TCP/IP client from 10.10.10.1:57842)"
I: [(null)] pulsecore/protocol-native.c: Client authenticated by IP ACL.
D: [(null)] pulsecore/protocol-native.c: Protocol version: remote 1073741857, local 23
D: [(null)] pulsecore/protocol-native.c: SHM possible: no
D: [(null)] pulsecore/protocol-native.c: Negotiated SHM: no
D: [(null)] modules/module-augment-properties.c: Looking for .desktop file for mpg123.bin
D: [(null)] pulsecore/memblockq.c: memblockq requested: maxlength=33554432, tlength=0, base=4, prebuf=0, minreq=1 maxrewind=0
D: [(null)] pulsecore/memblockq.c: memblockq sanitized: maxlength=33554432, tlength=33554432, base=4, prebuf=0, minreq=4 maxrewind=0
I: [(null)] pulsecore/sink-input.c: Created input 1 "ALSA Playback" on output with sample spec s16le 2ch 44100Hz and channel map front-left,front-righ
t
I: [(null)] pulsecore/sink-input.c: media.name = "ALSA Playback"
I: [(null)] pulsecore/sink-input.c: application.name = "ALSA plug-in [mpg123.bin]"
I: [(null)] pulsecore/sink-input.c: native-protocol.peer = "TCP/IP client from 10.10.10.1:57842"
I: [(null)] pulsecore/sink-input.c: native-protocol.version = "1073741857"
I: [(null)] pulsecore/sink-input.c: application.process.id = "10381"
I: [(null)] pulsecore/sink-input.c: application.process.user = "xxxxxx"
I: [(null)] pulsecore/sink-input.c: application.process.host = "yyyyyy"
I: [(null)] pulsecore/sink-input.c: application.process.binary = "mpg123.bin"
I: [(null)] pulsecore/sink-input.c: application.language = "C"
I: [(null)] pulsecore/sink-input.c: window.x11.display = "172.18.0.209:0"
I: [(null)] pulsecore/sink-input.c: application.process.machine_id = "5cb9f590ef094000838e27092969d95b"
I: [(null)] pulsecore/sink-input.c: module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [mpg123.bin]"
I: [(null)] pulsecore/protocol-native.c: Requested tlength=200.00 ms, minreq=66.67 ms
D: [(null)] pulsecore/protocol-native.c: Early requests mode enabled, configuring sink latency to minreq.
D: [(null)] pulsecore/memblockq.c: memblockq requested: maxlength=4194304, tlength=132300, base=4, prebuf=11760, minreq=44100 maxrewind=0
D: [(null)] pulsecore/memblockq.c: memblockq sanitized: maxlength=4194304, tlength=132300, base=4, prebuf=11760, minreq=44100 maxrewind=0
I: [(null)] pulsecore/protocol-native.c: Final latency 1000.00 ms = 250.00 ms + 2*250.00 ms + 250.00 ms

reference

  • Download the latest pulse audio release from http://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/ (latest is v1.1 at the time of writing).
  • unpack to somewhere you want. example: c:\pulse\
  • open c:\pulse\etc\default.pa
  • make sure you have something similar to:
    load-module module-native-protocol-tcp listen=0.0.0.0 auth-anonymous=1
    set-default-sink output
  • On your linux machine(s), open /etc/pulse/client.conf (you could possibly do the same with ~/.pulse/client.conf), make sure default-server is uncommented and set to the ip address of your windows machine (one you want to receive audio on)
  • restart pulseaudio on the linux machine(s). For ubuntu: pulseaudio -k, and for other distros, sudo service pulseaudio restart.
  • On your windows machine, launch pulseaudio.exe. This should open a simple terminal with a few warnings (nothing to worry about).
  • On your Linux machine(s), launch something that plays sound.