Skip to content

Commit

Permalink
Merge commit '30eb1cc'. This updates the code to 0.05.
Browse files Browse the repository at this point in the history
Conflicts:
	INSTALL
	Makefile
	README
	alac.c
	shairport.pl

Manually merged all conflicts.
  • Loading branch information
albertz committed Apr 14, 2011
2 parents 6f9c59c + 30eb1cc commit 34111eb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Shairport v0.04
Shairport v0.05
==============
James Laird <[email protected]>
April 11, 2011
April 13, 2011

What it is
----------
Expand Down Expand Up @@ -41,6 +41,8 @@ Changelog
* bugfix: ipv6 didn't work - IO::Socket::INET6 is required too
* 0.04 April 12, 2011
* cross-platform count_leading_zeros under GCC - will now compile cleanly on ARM and other platforms
* 0.05 April 13, 2011
* error-handling cleanup in the Perl script including more meaningful error messages, based on common problems seen


How to compile and install on Mac OSX 10.6
Expand Down
57 changes: 32 additions & 25 deletions shairport.pl
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,11 @@ sub POPE {
$SIG{PIPE} = \&POPE;


my $avahi_publish = fork();
if ($avahi_publish==0) {
exec 'avahi-publish-service',
join('', map { sprintf "%02X", $_ } @hw_addr) . "\@$apname",
"_raop._tcp",
"5000",
"tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1";
exec 'dns-sd', '-R',
join('', map { sprintf "%02X", $_ } @hw_addr) . "\@$apname",
"_raop._tcp",
".",
"5000",
"tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1";
die "could not run avahi-publish-service nor dns-sd";
}
our $avahi_publish;

sub REAP {
if ($avahi_publish == waitpid(-1, WNOHANG)) {
die("Avahi publishing failed!");
die("Avahi publishing failed! Do you have avahi-publish-service on your PATH?");
}
printf("***CHILD EXITED***\n");
$SIG{CHLD} = \&REAP;
Expand All @@ -93,21 +79,42 @@ sub REAP {

my %conns;

$SIG{TERM} = $SIG{INT} = $SIG{__DIE__} = sub {
$SIG{TERM} = $SIG{INT} = sub {
print "killed\n";
map { eval { kill $_->{decoder_pid} } } keys %conns;
kill 9, $avahi_publish;
exit(0);
exit 0;
};
$SIG{__DIE__} = sub {
print "died\n";
map { eval { kill $_->{decoder_pid} } } keys %conns;
kill 9, $avahi_publish;
};

$avahi_publish = fork();
if ($avahi_publish==0) {
exec 'avahi-publish-service',
join('', map { sprintf "%02X", $_ } @hw_addr) . "\@$apname",
"_raop._tcp",
"5000",
"tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1";
exec 'dns-sd', '-R',
join('', map { sprintf "%02X", $_ } @hw_addr) . "\@$apname",
"_raop._tcp",
".",
"5000",
"tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1";
die "could not run avahi-publish-service nor dns-sd";
}

my $airport_pem = join '', <DATA>;
my $rsa = Crypt::OpenSSL::RSA->new_private_key($airport_pem) || die "RSA private key import failed";

my $listen;
{
eval {
local $SIG{'__DIE__'};
$listen = new IO::Socket::INET6(Listen => 1,
local $SIG{__DIE__};
$listen = new IO::Socket::INET6(Listen => 1,
Domain => AF_INET6,
LocalPort => 5000,
ReuseAddr => 1,
Expand All @@ -118,12 +125,12 @@ sub REAP {
"* IO::Socket::INET6 not present! *\n",
"* Install this if iTunes won't play. *\n",
"**************************************\n\n";

$listen = new IO::Socket::INET(Listen => 1,
LocalPort => 5000,
ReuseAddr => 1,
Proto => 'tcp');
}

$listen ||= new IO::Socket::INET(Listen => 1,
LocalPort => 5000,
ReuseAddr => 1,
Proto => 'tcp');
}
die "Can't listen on port 5000: $!" unless $listen;

Expand Down

0 comments on commit 34111eb

Please sign in to comment.