Perl script is removed in favour of C. Stale documentation and initfiles
are removed for now also.
C interface works, but still needs work (for example, mDNS is missing) -
see TODO.
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.
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.
Signed-off-by: Gregor Fabritius <gre@g0r.de>
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.
Signed-off-by: Gregor Fabritius <gre@g0r.de>
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.
The math operations are all equivalent, but are simplified a bit for the
benefit of processors with slower floating point performance.
* Don't use float casts when we need to eventually convert to double
precision anyway.
* Use multiplication instead of division when possible.
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.
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.