3.1.2 pretty-print using clang-format

This commit is contained in:
Mike Brady
2017-09-07 12:02:00 +01:00
parent bbdefd9802
commit 3001f39bc5
9 changed files with 121 additions and 99 deletions
+5 -2
View File
@@ -713,7 +713,9 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
// if (conn->packet_count>500) { //for testing -- about 4 seconds of play first // if (conn->packet_count>500) { //for testing -- about 4 seconds of play first
if ((local_time_now > conn->time_of_last_audio_packet) && if ((local_time_now > conn->time_of_last_audio_packet) &&
(local_time_now - conn->time_of_last_audio_packet >= ct << 32)) { (local_time_now - conn->time_of_last_audio_packet >= ct << 32)) {
debug(1, "As Yeats almost said, \"Too long a silence / can make a stone of the heart\" from RTSP conversation %d.",conn->connection_number); debug(1, "As Yeats almost said, \"Too long a silence / can make a stone of the heart\" "
"from RTSP conversation %d.",
conn->connection_number);
conn->stop = 1; conn->stop = 1;
pthread_kill(conn->thread, SIGUSR1); pthread_kill(conn->thread, SIGUSR1);
} }
@@ -1835,7 +1837,8 @@ static void *player_thread_func(void *arg) {
char *long_silence = malloc(conn->output_bytes_per_frame * silence_length); char *long_silence = malloc(conn->output_bytes_per_frame * silence_length);
if (long_silence == NULL) if (long_silence == NULL)
die("Failed to allocate memory for a long_silence buffer of %d frames.",silence_length); die("Failed to allocate memory for a long_silence buffer of %d frames.",
silence_length);
memset(long_silence, 0, conn->output_bytes_per_frame * silence_length); memset(long_silence, 0, conn->output_bytes_per_frame * silence_length);
config.output->play((short *)long_silence, silence_length); config.output->play((short *)long_silence, silence_length);
free(long_silence); free(long_silence);
+6 -4
View File
@@ -254,7 +254,8 @@ void *rtp_control_receiver(void *arg) {
debug(3, "Too-short retransmitted audio packet received in control port, ignored."); debug(3, "Too-short retransmitted audio packet received in control port, ignored.");
} }
} else } else
debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1], nread); debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1],
nread);
} }
debug(3, "Control RTP thread interrupted. terminating."); debug(3, "Control RTP thread interrupted. terminating.");
@@ -290,7 +291,8 @@ void *rtp_timing_sender(void *arg) {
// debug(1,"Send a timing request"); // debug(1,"Send a timing request");
if (!conn->rtp_running) if (!conn->rtp_running)
debug(1,"rtp_timing_sender called without active stream in RTSP conversation thread %d!",conn->connection_number); debug(1, "rtp_timing_sender called without active stream in RTSP conversation thread %d!",
conn->connection_number);
// debug(1, "Requesting ntp timestamp exchange."); // debug(1, "Requesting ntp timestamp exchange.");
@@ -639,8 +641,8 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
inet_ntop(conn->connection_ip_family, self_addr, conn->self_ip_string, inet_ntop(conn->connection_ip_family, self_addr, conn->self_ip_string,
sizeof(conn->self_ip_string)); sizeof(conn->self_ip_string));
debug(1, "Set up play connection from %s to self at %s on RTSP conversation thread %d.", conn->client_ip_string, debug(1, "Set up play connection from %s to self at %s on RTSP conversation thread %d.",
conn->self_ip_string, conn->connection_number); conn->client_ip_string, conn->self_ip_string, conn->connection_number);
// set up a the record of the remote's control socket // set up a the record of the remote's control socket
struct addrinfo hints; struct addrinfo hints;
+33 -18
View File
@@ -266,7 +266,8 @@ static void cleanup_threads(void) {
// debug(2, "culling threads."); // debug(2, "culling threads.");
for (i = 0; i < nconns;) { for (i = 0; i < nconns;) {
if (conns[i]->running == 0) { if (conns[i]->running == 0) {
debug(3, "found RTSP connection thread %d in a non-running state.",conns[i]->connection_number); debug(3, "found RTSP connection thread %d in a non-running state.",
conns[i]->connection_number);
pthread_join(conns[i]->thread, &retval); pthread_join(conns[i]->thread, &retval);
debug(3, "RTSP connection thread %d deleted...", conns[i]->connection_number); debug(3, "RTSP connection thread %d deleted...", conns[i]->connection_number);
free(conns[i]); free(conns[i]);
@@ -652,10 +653,13 @@ static void handle_teardown(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
resp->respcode = 200; resp->respcode = 200;
msg_add_header(resp, "Connection", "close"); msg_add_header(resp, "Connection", "close");
debug(3, "TEARDOWN: synchronously terminating the player thread of RTSP conversation thread %d (2).",conn->connection_number); debug(3,
"TEARDOWN: synchronously terminating the player thread of RTSP conversation thread %d (2).",
conn->connection_number);
// if (rtsp_playing()) { // if (rtsp_playing()) {
player_stop(conn); player_stop(conn);
debug(3, "TEARDOWN: successful termination of playing thread of RTSP conversation thread %d.",conn->connection_number); debug(3, "TEARDOWN: successful termination of playing thread of RTSP conversation thread %d.",
conn->connection_number);
//} //}
} }
@@ -828,7 +832,8 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *
return; return;
error: error:
warn("Error in setup request -- unlocking play lock on RTSP conversation thread %d.",conn->connection_number); warn("Error in setup request -- unlocking play lock on RTSP conversation thread %d.",
conn->connection_number);
playing_conn = NULL; playing_conn = NULL;
pthread_mutex_unlock(&play_lock); pthread_mutex_unlock(&play_lock);
resp->respcode = 451; // invalid arguments resp->respcode = 451; // invalid arguments
@@ -1393,21 +1398,24 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
have_the_player = 1; have_the_player = 1;
} else { } else {
if (playing_conn) { if (playing_conn) {
debug(1,"RTSP Conversation thread %d already playing when asked by thread %d.",playing_conn->connection_number,conn->connection_number); debug(1, "RTSP Conversation thread %d already playing when asked by thread %d.",
playing_conn->connection_number, conn->connection_number);
} else { } else {
debug(1, "play_lock locked but no playing_conn."); debug(1, "play_lock locked but no playing_conn.");
} }
if (config.allow_session_interruption == 1) { if (config.allow_session_interruption == 1) {
// some other thread has the player ... ask it to relinquish the thread // some other thread has the player ... ask it to relinquish the thread
if (playing_conn) { if (playing_conn) {
debug(1, "ANNOUNCE: playing connection %d being interrupted by connection %d.",playing_conn->connection_number,conn->connection_number); debug(1, "ANNOUNCE: playing connection %d being interrupted by connection %d.",
playing_conn->connection_number, conn->connection_number);
if (playing_conn == conn) { if (playing_conn == conn) {
debug(1, "ANNOUNCE asking to stop itself."); debug(1, "ANNOUNCE asking to stop itself.");
} else { } else {
playing_conn->stop = 1; playing_conn->stop = 1;
memory_barrier(); memory_barrier();
pthread_kill(playing_conn->thread, SIGUSR1); pthread_kill(playing_conn->thread, SIGUSR1);
usleep(1000000); // here, it is possible for other connections to come in and nab the player. usleep(
1000000); // here, it is possible for other connections to come in and nab the player.
} }
} else { } else {
die("Non existent the_playing_conn with play_lock enabled."); die("Non existent the_playing_conn with play_lock enabled.");
@@ -1502,14 +1510,16 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
char *hdr = msg_get_header(req, "X-Apple-Client-Name"); char *hdr = msg_get_header(req, "X-Apple-Client-Name");
if (hdr) { if (hdr) {
debug(1, "Play connection from device named \"%s\" on RTSP conversation thread %d.", hdr,conn->connection_number); debug(1, "Play connection from device named \"%s\" on RTSP conversation thread %d.", hdr,
conn->connection_number);
#ifdef CONFIG_METADATA #ifdef CONFIG_METADATA
send_metadata('ssnc', 'snam', hdr, strlen(hdr), req, 1); send_metadata('ssnc', 'snam', hdr, strlen(hdr), req, 1);
#endif #endif
} }
hdr = msg_get_header(req, "User-Agent"); hdr = msg_get_header(req, "User-Agent");
if (hdr) { if (hdr) {
debug(1, "Play connection from user agent \"%s\" on RTSP conversation thread %d.", hdr,conn->connection_number); debug(1, "Play connection from user agent \"%s\" on RTSP conversation thread %d.", hdr,
conn->connection_number);
#ifdef CONFIG_METADATA #ifdef CONFIG_METADATA
send_metadata('ssnc', 'snua', hdr, strlen(hdr), req, 1); send_metadata('ssnc', 'snua', hdr, strlen(hdr), req, 1);
#endif #endif
@@ -1522,7 +1532,8 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
out: out:
if (resp->respcode != 200 && resp->respcode != 453) { if (resp->respcode != 200 && resp->respcode != 453) {
debug(1,"Error in handling ANNOUNCE on conversation thread %d. Unlocking the play lock.",conn->connection_number); debug(1, "Error in handling ANNOUNCE on conversation thread %d. Unlocking the play lock.",
conn->connection_number);
playing_conn = NULL; playing_conn = NULL;
pthread_mutex_unlock(&play_lock); pthread_mutex_unlock(&play_lock);
} }
@@ -1779,7 +1790,8 @@ static void *rtsp_conversation_thread_func(void *pconn) {
while (conn->stop == 0) { while (conn->stop == 0) {
reply = rtsp_read_request(conn, &req); reply = rtsp_read_request(conn, &req);
if (reply == rtsp_read_request_response_ok) { if (reply == rtsp_read_request_response_ok) {
debug(3, "RTSP thread %d received an RTSP Packet of type \"%s\":",conn->connection_number, req->method), debug(3, "RTSP thread %d received an RTSP Packet of type \"%s\":", conn->connection_number,
req->method),
debug_print_msg_headers(3, req); debug_print_msg_headers(3, req);
resp = msg_init(); resp = msg_init();
resp->respcode = 400; resp->respcode = 400;
@@ -1803,7 +1815,8 @@ static void *rtsp_conversation_thread_func(void *pconn) {
} }
} }
if (method_selected == 0) if (method_selected == 0)
debug(1, "RTSP thread %d: Unrecognised and unhandled rtsp request \"%s\".",conn->connection_number, req->method); debug(1, "RTSP thread %d: Unrecognised and unhandled rtsp request \"%s\".",
conn->connection_number, req->method);
} }
debug(3, "RTSP thread %d: RTSP Response:", conn->connection_number); debug(3, "RTSP thread %d: RTSP Response:", conn->connection_number);
debug_print_msg_headers(3, resp); debug_print_msg_headers(3, resp);
@@ -1813,9 +1826,11 @@ static void *rtsp_conversation_thread_func(void *pconn) {
} else { } else {
if ((reply == rtsp_read_request_response_immediate_shutdown_requested) || if ((reply == rtsp_read_request_response_immediate_shutdown_requested) ||
(reply == rtsp_read_request_response_channel_closed)) { (reply == rtsp_read_request_response_channel_closed)) {
debug(3, "Synchronously terminate playing thread of RTSP conversation thread %d.",conn->connection_number); debug(3, "Synchronously terminate playing thread of RTSP conversation thread %d.",
conn->connection_number);
player_stop(conn); player_stop(conn);
debug(3, "Successful termination of playing thread of RTSP conversation thread %d.",conn->connection_number); debug(3, "Successful termination of playing thread of RTSP conversation thread %d.",
conn->connection_number);
debug(3, "Request termination of RTSP conversation thread %d.", conn->connection_number); debug(3, "Request termination of RTSP conversation thread %d.", conn->connection_number);
conn->stop = 1; conn->stop = 1;
} else { } else {
@@ -2011,8 +2026,8 @@ void rtsp_listen_loop(void) {
send_ssnc_metadata('clip', strdup(remote_ip4), strlen(remote_ip4), 1); send_ssnc_metadata('clip', strdup(remote_ip4), strlen(remote_ip4), 1);
send_ssnc_metadata('svip', strdup(ip4), strlen(ip4), 1); send_ssnc_metadata('svip', strdup(ip4), strlen(ip4), 1);
#endif #endif
debug(1, "New RTSP connection from %s:%u to self at %s:%u on conversation thread %d.", remote_ip4, rport, ip4, debug(1, "New RTSP connection from %s:%u to self at %s:%u on conversation thread %d.",
tport,conn->connection_number); remote_ip4, rport, ip4, tport, conn->connection_number);
} }
#ifdef AF_INET6 #ifdef AF_INET6
if (local_info->SAFAMILY == AF_INET6) { if (local_info->SAFAMILY == AF_INET6) {
@@ -2032,8 +2047,8 @@ void rtsp_listen_loop(void) {
send_ssnc_metadata('clip', strdup(remote_ip6), strlen(remote_ip6), 1); send_ssnc_metadata('clip', strdup(remote_ip6), strlen(remote_ip6), 1);
send_ssnc_metadata('svip', strdup(ip6), strlen(ip6), 1); send_ssnc_metadata('svip', strdup(ip6), strlen(ip6), 1);
#endif #endif
debug(1, "New RTSP connection from [%s]:%u to self at [%s]:%u on conversation thread %d.", remote_ip6, rport, ip6, debug(1, "New RTSP connection from [%s]:%u to self at [%s]:%u on conversation thread %d.",
tport,conn->connection_number); remote_ip6, rport, ip6, tport, conn->connection_number);
} }
#endif #endif
+4 -2
View File
@@ -480,7 +480,8 @@ int parse_options(int argc, char **argv) {
#ifdef HAVE_LIBSOXR #ifdef HAVE_LIBSOXR
config.packet_stuffing = ST_soxr; config.packet_stuffing = ST_soxr;
#else #else
die("The soxr option not available because this version of shairport-sync was built without libsoxr " die("The soxr option not available because this version of shairport-sync was built "
"without libsoxr "
"support. Change the \"general/interpolation\" setting in the configuration file."); "support. Change the \"general/interpolation\" setting in the configuration file.");
#endif #endif
else else
@@ -848,7 +849,8 @@ int parse_options(int argc, char **argv) {
#ifdef HAVE_LIBSOXR #ifdef HAVE_LIBSOXR
config.packet_stuffing = ST_soxr; config.packet_stuffing = ST_soxr;
#else #else
die("The soxr option not available because this version of shairport-sync was built without libsoxr " die("The soxr option not available because this version of shairport-sync was built "
"without libsoxr "
"support. Change the -S option setting."); "support. Change the -S option setting.");
#endif #endif
else else