Florian Fainelli [Fri, 22 Feb 2013 14:52:26 +0000 (15:52 +0100)]
socketlib: properly fix the IPv6 to IPv4 fallback code.
With the current code, we do have the following on a system where IPv6
is completely disabled:
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address
family not supported by protocol)
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sa_family=AF_INET6, sin6_port=htons(5002), inet_pton(AF_INET6,
"::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1
EAFNOSUPPORT (Address family not supported by protocol)
The correct fix is to make a new call to getAddr() to ensure that the
entire struct addrinfo will be correctly filled out again with AF_INET
this time. This patch fixes.
Gregor Fabritius [Sun, 15 Jul 2012 23:27:08 +0000 (01:27 +0200)]
Initiating resync when receiving strange packet
The packet type 0x56, sequence number 0, containing 4 bytes (the first two are the sequence number of the previously requested packet) initiates a resync. Not sure what this packet is supposed to do, but it occurs after heavy requesting resending of packets. Seems to be an out of sync situation, so resyncing is not the worst idea.
Gregor Fabritius [Sun, 15 Jul 2012 21:10:28 +0000 (23:10 +0200)]
Fixed Issue #147: Segfaults on ShairPort version 0.05 C port
When requesting resend of packets a lot, iOS sometimes sends a packet with type 0x56 (Reply to resend request), but with sequence number 0 and length == 4. This short length leads to memory corruption later on when processing the packet: alac_decode() expects at least 16 bytes for AES IV. Therefore the segfault.
This fix ignores packets with length < 16, as seen in another implementation here:
http://fossies.org/dox/mythtv-0.25.1/mythraopconnection_8cpp_source.html#l00555
Please be aware that this just fixes the segfault. The suspicious packet seems to be an information of an out of sync situation, so it may deserve further attention.
Tim Douglas [Mon, 27 Feb 2012 07:30:59 +0000 (23:30 -0800)]
Add support for mDNSPublish, from the howl zeroconf implementation.
Howl hasn't been actively developed for some years now; their website 404s,
and the Wayback Machine archive of 2008 says it's dead.[1] Yet it's still
functional and is much smaller than dbus and avahi, which makes it useful
for embedded systems. In fact, OpenWrt has not dropped support for the howl
tools, and it's because of howl that I can fit a functional shairport and
supporting libraries and kernel onto the 4MB of flash in a TP-LINK
TL-WR703N.[2]
Dan McGee [Sat, 25 Feb 2012 19:57:46 +0000 (13:57 -0600)]
hairtunes: implement a simple LCG-based RNG for dithering
We are calling out to libc's rand() function, which has significant
overhead, especially since we are calling it 88200 times per second
(2 channels * 44100 samples).
Implement a very simple linear congruential generator in our code that
is plenty good enough for dithering purposes, and small enough for the
compiler to optimize and inline.
Dan McGee [Fri, 24 Feb 2012 21:50:41 +0000 (15:50 -0600)]
Use the audio buffer mutex appropriately
We need to use this any time we write to or access any of the
audio-buffer related variables. This also removes the need to use
'volatile', which cripples the compiler optimizations.
Dan McGee [Fri, 24 Feb 2012 21:47:07 +0000 (15:47 -0600)]
Use a pthread mutex around the volume settings
Using the `volatile` qualifier in multithreading code is never the right
answer. Mutexes should be used as was attempted with the audio buffer
code. Here, we implement a new mutex for the volume and fix_volume
globals, and grab a lock on it when necessary, which is for both reads
and writes.
Dan McGee [Fri, 24 Feb 2012 21:44:09 +0000 (15:44 -0600)]
Return the correct value from biquad_filt()
If you turned set `debug = 1` in hairtunes, you'd quickly get a mess of
debug messages that showed bf_est_drift in bf_est_update() going quicky
out of range toward a float NaN value (usually negative). Clearly the
presence of this `out` variable in biquad_filt was meant to be used, not
marked as unused.
Dan McGee [Fri, 24 Feb 2012 20:48:24 +0000 (14:48 -0600)]
hairtunes: use static keyword appropriately
This allows the compiler to do a much better job on this file, as it
currently can't inline most of the functions because they are
technically visible outside the file. Mark most functions and variables
static to let the compiler work.
Stef Simoens [Mon, 10 Oct 2011 21:48:41 +0000 (23:48 +0200)]
Improve resending of frames (and avoid missed frames)
- when requesting a packet, do not request an already received packet
- move the last-chance resend to buffer_get_frame
- check more often for missing frames
own checks show that some frames need to be requested up to 4 times
on bad connections
Stef Simoens [Mon, 10 Oct 2011 07:26:43 +0000 (09:26 +0200)]
new feature: run program on first connection / run program on last
disconnection
I was looking to trigger an action when I connect to shairport.
Basically, I want to switch on the stereo when I start playing music
over shairport (and I want to switch if off when I stop streaming).
Because my set-up will be different than any other set-up, I thought
about making it generic.
Two new command-line options --play_prog and --stop_prog take one
argument: the command line to start when the first connection is made or
when the last connection quits.
Example:
$ shairport.pl --play_prog="amixer set PCM 100%"
Stef Simoens [Mon, 10 Oct 2011 07:23:19 +0000 (09:23 +0200)]
Send "last-chance retry" only once
The last-chance resend was sometimes fired up to 6 times (probably while
receiving multiple new packets while playing the same buffer-data).
The following patch corrects this: only one retry is sent out.
For this to happen, I change abuf->ready to -1 ("1 retry sent out") and
by changing the other comparisons of abuf->ready to != 1.
Probably, this could be improved, by implementing a first check at t-30,
t-20, t-10, ...
sbleon [Wed, 3 Aug 2011 00:13:54 +0000 (21:13 -0300)]
Removed libao2 package from Debian/Ubuntu package install list since the package name varies on different releases. The proper version will always be installed because libao-dev depends on it.