Skip to content

Commit

Permalink
die/warn functions now have implicit newline at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
abrasive committed Jun 3, 2013
1 parent 0129db0 commit 8259ae6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
8 changes: 4 additions & 4 deletions audio_ao.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int init(int argc, char **argv) {
case 'd':
driver = ao_driver_id(optarg);
if (!driver)
die("could not find ao driver %s\n", optarg);
die("could not find ao driver %s", optarg);
break;
case 'i':
ao_append_option(&ao_opts, "id", optarg);
Expand All @@ -70,13 +70,13 @@ static int init(int argc, char **argv) {
case 'o':
mid = strchr(optarg, '=');
if (!mid)
die("Expected an = in audio option %s\n", optarg);
die("Expected an = in audio option %s", optarg);
*mid = 0;
ao_append_option(&ao_opts, optarg, mid+1);
break;
default:
help();
die("Invalid audio option -%c specified\n", opt);
die("Invalid audio option -%c specified", opt);
}
}

Expand All @@ -102,7 +102,7 @@ static void deinit(void) {

static void start(int sample_rate) {
if (sample_rate != 44100)
die("unexpected sample rate!\n");
die("unexpected sample rate!");
}

static void play(short buf[], int samples) {
Expand Down
2 changes: 2 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void die(char *format, ...) {
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
shairport_shutdown();
}

Expand All @@ -54,6 +55,7 @@ void warn(char *format, ...) {
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
}

void debug(int level, char *format, ...) {
Expand Down
2 changes: 1 addition & 1 deletion mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ void mdns_register(void) {
mdns_port, RECORD, NULL};
execvp(mac_argv[0], mac_argv);

die("Could not establish mDNS advertisement!\n");
die("Could not establish mDNS advertisement!");
}
14 changes: 7 additions & 7 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void player_put_packet(seq_t seqno, uint8_t *data, int len) {
} else if (seq_order(ab_read, seqno)) { // late but not yet played
abuf = audio_buffer + BUFIDX(seqno);
} else { // too late.
warn("late packet %04X (%04X:%04X)\n", seqno, ab_read, ab_write);
warn("late packet %04X (%04X:%04X)", seqno, ab_read, ab_write);
}
buf_fill = seq_diff(ab_read, ab_write);
pthread_mutex_unlock(&ab_mutex);
Expand Down Expand Up @@ -353,13 +353,13 @@ static short *buffer_get_frame(void) {
buf_fill = seq_diff(ab_read, ab_write);
if (buf_fill < 1 || !ab_synced) {
if (buf_fill < 1)
warn("underrun.\n");
warn("underrun.");
ab_buffering = 1;
pthread_mutex_unlock(&ab_mutex);
return 0;
}
if (buf_fill >= BUFFER_FRAMES) { // overrunning! uh-oh. restart at a sane distance
warn("overrun.\n");
warn("overrun.");
ab_read = ab_write - config.buffer_start_fill;
}
read = ab_read;
Expand All @@ -381,7 +381,7 @@ static short *buffer_get_frame(void) {

abuf_t *curframe = audio_buffer + BUFIDX(read);
if (!curframe->ready) {
warn("missing frame %04X.\n", read);
warn("missing frame %04X.", read);
memset(curframe->data, 0, FRAME_BYTES(frame_size));
}
curframe->ready = 0;
Expand Down Expand Up @@ -503,7 +503,7 @@ void player_flush(void) {

int player_play(stream_cfg *stream) {
if (config.buffer_start_fill > BUFFER_FRAMES)
die("specified buffer starting fill %d > buffer size %d\n",
die("specified buffer starting fill %d > buffer size %d",
config.buffer_start_fill, BUFFER_FRAMES);

AES_set_decrypt_key(stream->aeskey, 128, &aes);
Expand All @@ -518,7 +518,7 @@ int player_play(stream_cfg *stream) {
please_stop = 0;
if (config.cmd_start && !fork()) {
if (system(config.cmd_start))
warn("exec of external start command failed\n");
warn("exec of external start command failed");
exit(0);
}
config.output->start(sampling_rate);
Expand All @@ -533,7 +533,7 @@ void player_stop(void) {
config.output->stop();
if (config.cmd_stop && !fork()) {
if (system(config.cmd_stop))
warn("exec of external stop command failed\n");
warn("exec of external stop command failed");
exit(0);
}
free_buffer();
Expand Down
10 changes: 5 additions & 5 deletions rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void *rtp_receiver(void *arg) {
}
debug(1, "Unknown RTP packet of type 0x%02X length %d seqno %d\n", type, nread, seqno);
}
warn("Unknown RTP packet of type 0x%02X length %d\n", type, nread);
warn("Unknown RTP packet of type 0x%02X length %d", type, nread);
}

debug(1, "RTP thread interrupted. terminating.\n");
Expand Down Expand Up @@ -130,7 +130,7 @@ static int bind_port(SOCKADDR *remote) {

int rtp_setup(SOCKADDR *remote, int cport, int tport) {
if (running)
die("rtp_setup called with active stream!\n");
die("rtp_setup called with active stream!");

debug(1, "rtp_setup: cport=%d tport=%d\n", cport, tport);

Expand Down Expand Up @@ -162,7 +162,7 @@ int rtp_setup(SOCKADDR *remote, int cport, int tport) {

void rtp_shutdown(void) {
if (!running)
die("rtp_shutdown called without active stream!\n");
die("rtp_shutdown called without active stream!");

please_shutdown = 1;
pthread_kill(rtp_thread, SIGUSR1);
Expand All @@ -173,9 +173,9 @@ void rtp_shutdown(void) {

void rtp_request_resend(seq_t first, seq_t last) {
if (!running)
die("rtp_request_resend called without active stream!\n");
die("rtp_request_resend called without active stream!");

warn("requesting resend on %d packets (%04X:%04X)\n",
warn("requesting resend on %d packets (%04X:%04X)",
seq_diff(first,last) + 1, first, last);

char req[8]; // *not* a standard RTCP NACK
Expand Down
22 changes: 11 additions & 11 deletions rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static rtsp_message * msg_init(void) {

static int msg_add_header(rtsp_message *msg, char *name, char *value) {
if (msg->nheaders >= sizeof(msg->name)/sizeof(char*)) {
warn("too many headers?!\n");
warn("too many headers?!");
return 1;
}

Expand Down Expand Up @@ -193,7 +193,7 @@ static int msg_handle_line(rtsp_message **pmsg, char *line) {
char *p;
p = strstr(line, ": ");
if (!p) {
warn("bad header: >>%s<<\n", line);
warn("bad header: >>%s<<", line);
goto fail;
}
*p = 0;
Expand Down Expand Up @@ -248,7 +248,7 @@ static rtsp_message * rtsp_read_request(int fd) {
msg_size = msg_handle_line(&msg, buf);

if (!msg) {
warn("no RTSP header received\n");
warn("no RTSP header received");
goto shutdown;
}

Expand Down Expand Up @@ -431,14 +431,14 @@ static void handle_announce(rtsp_conn_info *conn,
}

if (!paesiv || !prsaaeskey || !pfmtp) {
warn("required params missing from announce\n");
warn("required params missing from announce");
return;
}

int len, keylen;
uint8_t *aesiv = base64_dec(paesiv, &len);
if (len != 16) {
warn("client announced aeskey of %d bytes, wanted 16\n", len);
warn("client announced aeskey of %d bytes, wanted 16", len);
free(aesiv);
return;
}
Expand All @@ -449,7 +449,7 @@ static void handle_announce(rtsp_conn_info *conn,
uint8_t *aeskey = rsa_apply(rsaaeskey, len, &keylen, RSA_MODE_KEY);
free(rsaaeskey);
if (keylen != 16) {
warn("client announced rsaaeskey of %d bytes, wanted 16\n", keylen);
warn("client announced rsaaeskey of %d bytes, wanted 16", keylen);
free(aeskey);
return;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ static void apple_challenge(int fd, rtsp_message *req, rtsp_message *resp) {
memset(buf, 0, sizeof(buf));

if (chall_len > 16) {
warn("oversized Apple-Challenge!\n");
warn("oversized Apple-Challenge!");
free(chall);
return;
}
Expand Down Expand Up @@ -622,7 +622,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {

if (!strcmp(response, buf))
return 0;
warn("auth failed\n");
warn("auth failed");

authenticate:
resp->respcode = 401;
Expand Down Expand Up @@ -729,7 +729,7 @@ void rtsp_listen_loop(void) {

ret = getaddrinfo(NULL, portstr, &hints, &info);
if (ret) {
die("getaddrinfo failed: %s\n", gai_strerror(ret));
die("getaddrinfo failed: %s", gai_strerror(ret));
}

for (p=info; p; p=p->ai_next) {
Expand Down Expand Up @@ -766,7 +766,7 @@ void rtsp_listen_loop(void) {
freeaddrinfo(info);

if (!nsock)
die("could not bind any listen sockets!\n");
die("could not bind any listen sockets!");


int maxfd = -1;
Expand Down Expand Up @@ -816,5 +816,5 @@ void rtsp_listen_loop(void) {
FD_SET(sockfd[i], &fds);
}
perror("select");
die("fell out of the RTSP select loop\n");
die("fell out of the RTSP select loop");
}
2 changes: 1 addition & 1 deletion shairport.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int main(int argc, char **argv) {
config.output = audio_get_output(config.output_name);
if (!config.output) {
audio_ls_outputs();
die("Invalid audio output specified!\n");
die("Invalid audio output specified!");
}
config.output->init(argc-audio_arg, argv+audio_arg);

Expand Down

0 comments on commit 8259ae6

Please sign in to comment.