clang format

This commit is contained in:
Mike Brady
2021-05-02 14:35:31 +01:00
parent 04c0d97685
commit 6a13062100
4 changed files with 48 additions and 50 deletions
+4 -4
View File
@@ -1926,10 +1926,10 @@ void *player_thread_func(void *arg) {
if (conn->timing_type == ts_ntp) {
#endif
// create and start the timing, control and audio receiver threads
pthread_create(&conn->rtp_audio_thread, NULL, &rtp_audio_receiver, (void *)conn);
pthread_create(&conn->rtp_control_thread, NULL, &rtp_control_receiver, (void *)conn);
pthread_create(&conn->rtp_timing_thread, NULL, &rtp_timing_receiver, (void *)conn);
// create and start the timing, control and audio receiver threads
pthread_create(&conn->rtp_audio_thread, NULL, &rtp_audio_receiver, (void *)conn);
pthread_create(&conn->rtp_control_thread, NULL, &rtp_control_receiver, (void *)conn);
pthread_create(&conn->rtp_timing_thread, NULL, &rtp_timing_receiver, (void *)conn);
#ifdef CONFIG_AIRPLAY_2
}
+4 -5
View File
@@ -81,7 +81,6 @@ typedef enum {
ast_apple_lossless,
} audio_stream_type;
typedef struct {
int encrypted;
uint8_t aesiv[16], aeskey[16];
@@ -104,9 +103,9 @@ typedef struct file_cipher_context {
#endif
typedef struct {
int connection_number; // for debug ID purposes, nothing else...
int resend_interval; // this is really just for debugging
char *UserAgent; // free this on teardown
int connection_number; // for debug ID purposes, nothing else...
int resend_interval; // this is really just for debugging
char *UserAgent; // free this on teardown
int AirPlayVersion; // zero if not an AirPlay session. Used to help calculate latency
uint32_t latency; // the actual latency used for this play session
uint32_t minimum_latency; // set if an a=min-latency: line appears in the ANNOUNCE message; zero
@@ -242,7 +241,7 @@ typedef struct {
#ifdef CONFIG_AIRPLAY_2
airplay_t airplay_type; // are we using AirPlay 1 or AirPlay 2 protocol on this connection?
timing_t timing_type; // are we using NTP or PTP on this connection?
timing_t timing_type; // are we using NTP or PTP on this connection?
pthread_t rtp_event_thread;
pthread_t rtp_ap2_control_thread;
+36 -36
View File
@@ -120,7 +120,7 @@ void rtp_audio_receiver_cleanup_handler(__attribute__((unused)) void *arg) {
}
void *rtp_audio_receiver(void *arg) {
debug(1,"rtp_audio_receiver start");
debug(1, "rtp_audio_receiver start");
pthread_cleanup_push(rtp_audio_receiver_cleanup_handler, arg);
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
@@ -259,7 +259,7 @@ void rtp_control_handler_cleanup_handler(__attribute__((unused)) void *arg) {
}
void *rtp_control_receiver(void *arg) {
debug(1,"rtp_control_receiver start");
debug(1, "rtp_control_receiver start");
pthread_cleanup_push(rtp_control_handler_cleanup_handler, arg);
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
@@ -290,8 +290,8 @@ void *rtp_control_receiver(void *arg) {
obfp += 2;
};
*obfp = 0;
// get raw timestamp information
// I think that a good way to understand these timestamps is that
// (1) the rtlt below is the timestamp of the frame that should be playing at the
@@ -302,19 +302,19 @@ void *rtp_control_receiver(void *arg) {
// Thus, (3) the latency can be calculated by subtracting the second from the
// first.
// There must be more to it -- there something missing.
// In addition, it seems that if the value of the short represented by the second
// pair of bytes in the packet is 7
// then an extra time lag is expected to be added, presumably by
// the AirPort Express.
// Best guess is that this delay is 11,025 frames.
uint32_t rtlt = nctohl(&packet[4]); // raw timestamp less latency
uint32_t rt = nctohl(&packet[16]); // raw timestamp
uint32_t fl = nctohs(&packet[2]); //
debug(1,"Sync Packet of %d bytes received: \"%s\", flags: %d, timestamps %u and %u,
giving a latency of %d frames.",plen,obf,fl,rt,rtlt,rt-rtlt);
//debug(1,"Monotonic timestamps are: %" PRId64 " and %" PRId64 "
@@ -508,7 +508,7 @@ void rtp_timing_sender_cleanup_handler(void *arg) {
}
void *rtp_timing_sender(void *arg) {
debug(1,"rtp_timing_sender start");
debug(1, "rtp_timing_sender start");
pthread_cleanup_push(rtp_timing_sender_cleanup_handler, arg);
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
struct timing_request {
@@ -610,7 +610,7 @@ void rtp_timing_receiver_cleanup_handler(void *arg) {
}
void *rtp_timing_receiver(void *arg) {
debug(1,"rtp_timing_receiver start");
debug(1, "rtp_timing_receiver start");
pthread_cleanup_push(rtp_timing_receiver_cleanup_handler, arg);
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
@@ -1127,16 +1127,16 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
req[0] = 0x80;
#ifdef CONFIG_AIRPLAY_2
if (conn->airplay_type == ap_2) {
if (conn->ap2_remote_control_socket_addr_length == 0) {
debug(2, "No remote socket -- skipping the resend");
return; // hack
}
req[1] = 0xD5; // Airplay 2 'resend'
if (conn->ap2_remote_control_socket_addr_length == 0) {
debug(2, "No remote socket -- skipping the resend");
return; // hack
}
req[1] = 0xD5; // Airplay 2 'resend'
} else {
#endif
req[1] = (char)0x55 | (char)0x80; // Apple 'resend'
req[1] = (char)0x55 | (char)0x80; // Apple 'resend'
#ifdef CONFIG_AIRPLAY_2
}
}
#endif
*(unsigned short *)(req + 2) = htons(1); // our sequence number
*(unsigned short *)(req + 4) = htons(first); // missed seqnum
@@ -1156,29 +1156,29 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
timeout.tv_usec = 100000;
int response;
#ifdef CONFIG_AIRPLAY_2
if (conn->airplay_type == ap_2) {
if (setsockopt(conn->ap2_control_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
sizeof(timeout)) < 0)
debug(1, "Can't set timeout on resend request socket.");
response = sendto(conn->ap2_control_socket, req, sizeof(req), 0,
(struct sockaddr *)&conn->ap2_remote_control_socket_addr,
conn->ap2_remote_control_socket_addr_length);
} else {
if (conn->airplay_type == ap_2) {
if (setsockopt(conn->ap2_control_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
sizeof(timeout)) < 0)
debug(1, "Can't set timeout on resend request socket.");
response = sendto(conn->ap2_control_socket, req, sizeof(req), 0,
(struct sockaddr *)&conn->ap2_remote_control_socket_addr,
conn->ap2_remote_control_socket_addr_length);
} else {
#endif
if (setsockopt(conn->control_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
sizeof(timeout)) < 0)
debug(1, "Can't set timeout on resend request socket.");
socklen_t msgsize = sizeof(struct sockaddr_in);
if (setsockopt(conn->control_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
sizeof(timeout)) < 0)
debug(1, "Can't set timeout on resend request socket.");
socklen_t msgsize = sizeof(struct sockaddr_in);
#ifdef AF_INET6
if (conn->rtp_client_control_socket.SAFAMILY == AF_INET6) {
msgsize = sizeof(struct sockaddr_in6);
}
if (conn->rtp_client_control_socket.SAFAMILY == AF_INET6) {
msgsize = sizeof(struct sockaddr_in6);
}
#endif
response = sendto(conn->control_socket, req, sizeof(req), 0,
(struct sockaddr *)&conn->rtp_client_control_socket, msgsize);
response = sendto(conn->control_socket, req, sizeof(req), 0,
(struct sockaddr *)&conn->rtp_client_control_socket, msgsize);
#ifdef CONFIG_AIRPLAY_2
}
}
#endif
if (response == -1) {
char em[1024];
+4 -5
View File
@@ -2091,7 +2091,7 @@ void handle_options(rtsp_conn_info *conn, __attribute__((unused)) rtsp_message *
}
void handle_teardown_2(rtsp_conn_info *conn, __attribute__((unused)) rtsp_message *req,
rtsp_message *resp) {
rtsp_message *resp) {
debug(2, "Connection %d: TEARDOWN", conn->connection_number);
// debug_log_rtsp_message(1, "TEARDOWN: ", req);
@@ -2221,7 +2221,6 @@ void handle_teardown(rtsp_conn_info *conn, __attribute__((unused)) rtsp_message
}
}
void handle_flush(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
// TODO -- don't know what this is for in AP2
debug_log_rtsp_message(2, "FLUSH request", req);
@@ -3815,7 +3814,8 @@ static struct method_handler {
#else
static struct method_handler {
char *method;
void (*handler)(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp); // for AirPlay 1 only
void (*handler)(rtsp_conn_info *conn, rtsp_message *req,
rtsp_message *resp); // for AirPlay 1 only
} method_handlers[] = {{"OPTIONS", handle_options},
{"ANNOUNCE", handle_announce},
{"FLUSH", handle_flush},
@@ -4631,11 +4631,10 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) {
memset(conn, 0, sizeof(rtsp_conn_info));
conn->connection_number = RTSP_connection_index++;
#ifdef CONFIG_AIRPLAY_2
conn->airplay_type = ap_2; // changed if an ANNOUNCE is received
conn->airplay_type = ap_2; // changed if an ANNOUNCE is received
conn->timing_type = ts_ptp; // changed if an ANNOUNCE is received
#endif
socklen_t size_of_reply = sizeof(SOCKADDR);
conn->fd = accept(acceptfd, (struct sockaddr *)&conn->remote, &size_of_reply);
if (conn->fd < 0) {