Streaming Audio from Windows to PulseAudio Server

2008-09-22 09:01

PulseAudio is a great network audio server for Linux. It allows me to stream audio between machines. However, the biggest problem with PulseAudio is that it doesn’t have a descent client implementation for Windows. There are a couple known workarounds such as using WinESD, but they are all pretty experimental. Also, the Win32 binary build didn’t work for me, perhaps because it’s somewhat outdated and buggy.

My first try was to use LineInCode and Netcat for Windows on the client side and to use module-simple-protocol-tcp on the server side. After adding -L "module-simple-protocol-tcp port=4712 rate=44100 format=s16le channels=2" option to the PulseAudio startup option, I was able to stream audio from Windows to PulseAudio server using the following command:

linco.exe -B 16 -C 2 -R 44100 | nc.exe <host> 4712

However, PulseAudio dies whenever the connection is closed because of a known issue of module-simple-protocol-tcp. I wrote some script that restarts PulseAudio whenever it dies, but I realized there’s a better solution – OpenSSH.

I have installed a Cygwin build of OpenSSH, and replaced Netcat with it:

linco.exe -B 16 -C 2 -R 44100 | ssh.exe <user@host> "cat - | pacat --playback"

This solution works without module-simple-protocol-tcp, and therefore there’s no need to restart the PulseAudio server on disconnection. Better security is another bonus. Instead, it requires a running SSH server. If SSHD is not running in the PulseAudio server, you can give it a little twist:

linco.exe -B 16 -C 2 -R 44100 | ssh.exe <user@otherhost> "cat - | pacat --server <host> --playback"

In case your Windows machine doesn’t have a sound card or it doesn’t allow you to capture the audio stream, you might want to use Virtual Audio Cable. It’s a commercial software, but it worths a purchase.

You might also want to set up a passwordless login so you don’t have to enter the password every time you stream the audio.

---

Comment

9 Comments

thank you so much %)

rstets · 2008-10-09 22:36 · # · Reply

@rstets: You’re welcome! :)

Trustin Lee · 2008-10-09 22:53 · # · Reply

Hmmm, how did you manage to send anything but microphone to PulseAudio server from Windows? Linco transfer only Audio Input on my machine :(

kotnik · 2009-02-24 01:49 · # · Reply

@kotnik: Virtual Audio Cable just worked for me. Perhaps linco might have an option which allows you to choose a device? I’m not sure anyway because I didn’t try that way. I’d recommend Virtual Audio Cable to save your effort. It doesn’t cost that much. Or.. perhaps there might be some open source alternative somewhere. Please let me know if you found one. :)

Trustin Lee · 2009-02-24 03:29 · # · Reply

Thanks…

I’ll try to find some solution that doesn’t involve proprietary software. If I stumble upon anything, I’ll let you know ;)

kotnik · 2009-02-25 17:43 · # · Reply

How did you reduce the latency in your setup? I’m using Plink instead of ssh.exe, but other than that, I have the same setup as you.
However, I’m getting latencies of at least 1.5 seconds, which seems a bit ridiculous. Did you do anything to reduce it?

Walter Huf · 2009-03-26 08:29 · # · Reply

@Walter: Actually, I just live with it. I think it’s fine unless you are playing video. I use it only for playing music.

Trustin Lee · 2009-03-26 16:49 · # · Reply

Thanks for this post. I run Ubuntu 8.10 as my host operating system but do development work in Windows (C#) so I run VMware Workstation. Up until this point I was never able to get sound fully working inside a guest Windows operating system – I would always get obnoxious stuttering or the audio would speed-up/cut-out randomly. I’ve tried multiple sound cards and numerous settings tweaks to both PulseAudio & the individual virtual machines.

But now, with Virtual Audio Cable and your setup with LiveIncode & SSH, I’m able to route sound over to my host Ubuntu’s PulseAudio server and have it be pretty much flawless.

Thanks.

Mulchman · 2009-04-04 12:00 · # · Reply

@Mulchman: Great to hear that my tip was helpful. :)

Trustin Lee · 2009-04-04 15:18 · # · Reply

 
  • Preview 버튼 누르고 reCAPTCHA 입력 후 Submit 버튼까지 눌러야 실제로 게시됩니다.
  • Make sure to answer the reCAPTCHA and click the Submit button to get your comment posted. It's not enough to click the Preview button only! -- See why.
---