Title: Nokia N900 as pulseaudio sink and source

This blog post explains how to use your awesome Nokia N900 as audio sink, that is, you can output your laptop/desktop audio to the N900.

This also allows you to then route the audio that is being sent to your N900 to be transmitted over FM, using the N900 FM transmitter.

My laptop currently does not have a working sound card on the Mainline kernel - so this is a hack that I use every now and then.

This blog post assumes some familiarity with pulseaudio. It covers quite some basics, but some things should be obvious enough that I do not need to explain them.

Pulseaudio on the N900, a bit of history

The N900 runs Pulseaudio 0.9.15, with a few custom Nokia patches on top. I got a lot of information from the thread Why is Pulseaudio crippled on the N900?, it even includes a working stream-audio-to-n900 example that works with ancient pulseaudio versions.

The problem was that the N900 pulseaudio was not compatible with newer versions of pulseaudio. Recently the CSSU (Community Seamless Software Update) for the N900 has patched pulseaudio so that it is able to communicate with more recent pulseaudio software.

With an up to date N900 using CSSU, we can (again) stream audio to and from the N900.

On the N900 you need to install pulseaudio-module-extra, this provides you with the necessary module-native-protocol-tcp. Then, add the following to /etc/pulse/system.pa:

.ifexists module-native-protocol-tcp.so
load-module module-native-protocol-tcp auth-anonymous=1

auth-anonymous allows everyone in the same ip range to connect to your device running on your pulseaudio. I believe this to likely a security hazard, we cover making this setup more secure in the section Securing Pulseaudio.

Restart pulseaudio on the n900 with (as root):

# stop pulseaudio
# start pulseaudio

Streaming, cheap and easy way

You can test if this works right away. Take your favourite audio player, I used mpv:

PULSE_SERVER=N900_IP_HERE mpv my-audio-file.wav

And patiently wait - it may take quite some time before the actual streaming starts, depending on if you're using wifi or usbnet. If all is well, you should now hear sound coming from your N900. If you see something playing, but don't hear anything, see if the sound of your N900 is turned down or muted.

Streaming more transparently

What we did in the previous section was nice, but not particularly transparent: you need to set the PULSE_SERVER environment variable for every application and it is not possible to switch on the fly, since changing the environment typically requires an application restart.

You can also add the n900 as a sink in your laptop pulseaudio, add the following line to your laptop /etc/pulse/default.pa:

load-module module-tunnel-sink-new sink_name="n900" server=N900_IP_HERE

Restart pulseaudio on your laptop (I do this as follows, but it's a bit hacky):

killall pulseaudio ; pulseaudio -vv --exit-idle-time=-1

Then, issue the following command in another terminal:

pacmd set-default-sink n900

Now the n900 is set up as your default sink. Now you can just start an application as you would usually:

mpv my-audio-file.wav

Again, wait a bit for the connection to initialise -- I think pulseaudio does some latency calculations before it starts to actually stream to the n900. You can work around this by issuing the following command after you have set the n900 as your default sync (and not killing it):

aplay /dev/zero  -f cd
Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

This will always keep the connection to your n900 open -- and there will be no more startup latency.

Securing Pulseaudio

Pulseaudio supports authorisation cookies. This means your laptop and the n900 can share a secret file (the cookie). On my laptop I had both a $HOME/.pulse-cookie and $HOME/.config/pulse/cookie file. pulseaudio used the latter - $HOME/.config/pulse/cookie, so I made sure those two files contained the same.

Put the following in /etc/pulse/system.pa:

.ifexists module-native-protocol-tcp.so
load-module module-native-protocol-tcp auth-cookie=/etc/pulse/shared-cookie auth-cookie-enabled=1

This tells pulseaudio to load the cookie from /etc/pulse/shared-cookie. Next you need to create this file. Copy the file .config/pulse/cookie from your laptop to your n900, and place it in /etc/pulse/shared-cookie:

scp .config/pulse/cookie root@nokia-n900:/etc/pulse/shared-cookie

Additionally, run the following on your n900, as root:

chmod 600 /etc/pulse/shared-cookie
chown pulse:pulse /etc/pulse/shared-cookie

Again, restart pulseaudio with:

# stop pulseaudio
# start pulseaudio

Voila! Now your pulseaudio supports cookie based authentication.

For every device you want to add, simply add the cookie file.

If you want you your module-tunnel-sink-new to work, also add the cookie argument (and copy the file to /etc/pulse/shared-cookie on your laptop:

load-module module-tunnel-sink-new sink_name="n900" server= cookie=/etc/pulse/shared-cookie

Without pulseaudio?

It is also possible to send audio in a different way, for example using netcat or ssh in combination with sox, aplay, and arecord. I managed to get this to work - but it had a terrible latency (likely due to buffering - I could perhaps fix it using stdbuf). You can look at the nifty tool datenwolf made a few years ago: http://datenwolf.net/bl20120213-0001/


Latency can be an issue - as I mentioned at the start of the article, doing internet over a wire (either ethernet cables or usb cables with usbnet) improves latency and throughput, typically.

An alternative would be to reduce the samples per second that pulseaudio has to communicate, I have not managed to change the sample rate. The module-tunnel-sink-new module of pulseaudio has support to set the sample rate, but that didn't work for me for some reason.

In some rare cases, the N900 unexpectedly crashes and reboots.


There is always some latency involved in networked audio - over cables I barely notice any latency, but if you're doing this over wifi, it may end up being unusable, but it may also just work. Most of the time when I use my n900 as audio sink, I communicate with it over usb networking, as that has a better latency and throughput than wireless.

While this hack does not require pulseaudio, I got very decent results using pulseaudio, especially regarding latency, ironically enough. Of course, the latency is I am referring to is latency when throwing audio over the network (in this case - wifi even), not real-time latency that JACK offers.

Most of what I wrote in this article is not n900 specific, and you can also use these steps to set up a networked pulseaudio connection between two other devices support pulseaudio. For example, this setup can work both ways, you can also use module-tunnel-{sink,source} on the n900 and redirect all audio from the n900 to your laptop.

Finally, before I conclude this post I have to say I am not a particular fan of pulseaudio - but it does seem to have gotten better since Lennart P. focussed his attention on other projects...