Skip to content

Commit

Permalink
Merge pull request abrasive#120 from stefdude/master
Browse files Browse the repository at this point in the history
1 x bugfix, 1 x improvement, 1 x new feature
  • Loading branch information
albertz committed Oct 10, 2011
2 parents ca6dcc7 + 9796ac3 commit 2d8f4af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions hairtunes.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ void buffer_put_packet(seq_t seqno, char *data, int len) {
// check if the t+10th packet has arrived... last-chance resend
read = ab_read + 10;
abuf = audio_buffer + BUFIDX(read);
if (!abuf->ready)
if (abuf->ready != 1) {
rtp_request_resend(read, read);
abuf->ready = -1;
}
}
}

Expand Down Expand Up @@ -671,7 +673,7 @@ short *buffer_get_frame(void) {
bf_est_update(buf_fill);

volatile abuf_t *curframe = audio_buffer + BUFIDX(read);
if (!curframe->ready) {
if (curframe->ready != 1) {
fprintf(stderr, "\nmissing frame.\n");
memset(curframe->data, 0, FRAME_BYTES);
}
Expand Down
3 changes: 2 additions & 1 deletion hairtunes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *pFmtpstr, int pCtrlPort, i
int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId);

// default buffer size
#define BUFFER_FRAMES 320
// needs to be a power of 2 because of the way BUFIDX(seqno) works
#define BUFFER_FRAMES 512

#endif
17 changes: 17 additions & 0 deletions shairport.pl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
my $mac;
# SB volume
my $volume;
# custom play and stop program
my $play_prog;
my $stop_prog;
# output debugging information
my $verbose;
# where to write PID
Expand All @@ -97,6 +100,8 @@
"s|squeezebox" => \$squeeze,
"c|cliport=s" => \$cliport,
"m|mac=s" => \$mac,
"play_prog=s" => \$play_prog,
"stop_prog=s" => \$stop_prog,
"l|volume=s" => \$volume,
"h|help" => \$help);

Expand All @@ -117,6 +122,8 @@ sub usage {
" -c --cliport=port Sets the SBS CLI port\n",
" -m --mac=address Sets the SB target device\n",
" -l --volume=level Sets the SB volume level (in %)\n",
" --play_prog=cmdline Program to start on 1st connection\n",
" --stop_prog=cmdline Program to start on last disconnection\n",
" -d Daemon mode\n",
" -w --writepid=path Write PID to this location\n",
" -v --verbose Print debugging messages\n",
Expand Down Expand Up @@ -491,6 +498,11 @@ sub performSqueezeboxSetup {
if (defined($squeeze) && $squeeze) {
&performSqueezeboxSetup();
}

# the 2nd connection is a player connection
if (defined($play_prog) && $sel->count() == 2) {
system($play_prog);
}
} else {
if (eof($fh)) {
print "Closed: $fh\n" if $verbose;
Expand All @@ -502,6 +514,11 @@ sub performSqueezeboxSetup {
eval { kill $conns{$fh}{decoder_pid} };
}
delete $conns{$fh};

# 1 connection means no connection
if (defined($stop_prog) && $sel->count() == 1) {
system($stop_prog);
}
next;
}
if (exists $conns{$fh}) {
Expand Down

0 comments on commit 2d8f4af

Please sign in to comment.