I've been having this problem too on Ubuntu 12.04, but I think I've got
to the bottom of it.

Using the ss utility with -m shows that the write buffer is limited to
68KB. The Linux stack is measuring the link speed at 2-4Mbps, which
should be enough. However, with roughly 60-70ms RTT latency (it's over
wireless), and with such a small buffer, keeping a steady flow of data
to the Squeezebox requires the buffer to be constantly topped up. This
is not possible in spotifyd, because the libspotify code tends to block
for roughly 190ms at a time in the same thread that sends data to the
Squeezebox. Consequently, the slightest hiccup in the wireless link will
cause the drop-outs we've been experiencing.

I've tried playing about with the TCP buffer tunings, but it now appears
that this won't work because spotifyd calls setsockopt to set the send
buffer size to 32768 (which the Linux stack doubles to 65536 to cover
overheads) and this effectively switches off the write buffer autotuning
processing. 

As an experiment I've made the following changes.

1. Changed the net.core.wmem_max setting from the rather low default
value of 131072 to 12582912.
2. Modified spotifyd64 with hexedit to call setsockopt with a value of
8388608.

The result of these changes is that the plugin is now quite happily
streaming to the Squeezebox without drop-outs.

Three potential solutions spring to mind.

1. Move the send processing to another thread. (Complex, but requires no
network buffer tuning whatsoever)
2. Specify a much larger buffer size in setsockopt (Easy, requires only
net.core.wmem_max to be changed)
3. Don't call setsockopt at all (Easy, but requires user changes of
net.core.wmem_max and net.ipv4.tcp_wmem.

Given the asymmetrical profile of data being sent to and from the
Squeezebox, it might also help to call setsockopt to set TCP_NODELAY on
the socket in order to disable the Nagle algorithm if that isn't already
done.

I hope this is of some use.


------------------------------------------------------------------------
Stevie P's Profile: http://forums.slimdevices.com/member.php?userid=9358
View this thread: http://forums.slimdevices.com/showthread.php?t=97851

_______________________________________________
plugins mailing list
plugins@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to