From: Mike Brady Date: Mon, 21 Aug 2017 16:08:41 +0000 (+0200) Subject: Add index numbers for each RTSP conversation thread, to help figure debug messages... X-Git-Tag: 3.2d1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abd342553a710988c4ab9ee2ce5393aa00dde744;p=thirdparty%2Fshairport-sync.git Add index numbers for each RTSP conversation thread, to help figure debug messages out better. --- diff --git a/player.h b/player.h index d69792c6..d5e67279 100644 --- a/player.h +++ b/player.h @@ -52,6 +52,7 @@ typedef struct { } stream_cfg; typedef struct { + int connection_number; // for debug ID purposes, nothing else... int fd; int authorized; // set if a password is required and has been supplied stream_cfg stream; diff --git a/rtp.c b/rtp.c index dfd15b95..cb1945e6 100644 --- a/rtp.c +++ b/rtp.c @@ -713,6 +713,9 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time, pthread_mutex_lock(&conn->reference_time_mutex); *timestamp = conn->reference_timestamp; *timestamp_time = conn->reference_timestamp_time; + if ((*timestamp == 0) && (*timestamp_time == 0)) { + debug(1,"Reference timestamp is invalid."); + } *remote_timestamp_time = conn->remote_reference_timestamp_time; pthread_mutex_unlock(&conn->reference_time_mutex); } diff --git a/rtsp.c b/rtsp.c index 36d7b5ea..cb3eea05 100644 --- a/rtsp.c +++ b/rtsp.c @@ -96,6 +96,8 @@ static rtsp_conn_info *playing_conn = NULL; // the data structure representing the connection that has the player. static rtsp_conn_info **conns = NULL; +int RTSP_connection_index = 0; + void memory_barrier() { pthread_mutex_lock(&barrier_mutex); pthread_mutex_unlock(&barrier_mutex); @@ -1771,11 +1773,12 @@ static void *rtsp_conversation_thread_func(void *pconn) { char *hdr, *auth_nonce = NULL; enum rtsp_read_request_response reply; - + + conn->running = 1; do { reply = rtsp_read_request(conn, &req); if (reply == rtsp_read_request_response_ok) { - debug(3, "RTSP Packet received of type \"%s\":", 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); resp = msg_init(); resp->respcode = 400; @@ -1812,7 +1815,7 @@ static void *rtsp_conversation_thread_func(void *pconn) { } } while (reply != rtsp_read_request_response_shutdown_requested); - debug(1, "Closing down RTSP conversation thread..."); + debug(1, "Closing down RTSP conversation thread %d...",conn->connection_number); if (rtsp_playing()) { player_stop(&conn->player_thread, conn); // might be less noisy doing this first rtp_shutdown(conn); @@ -1831,7 +1834,7 @@ static void *rtsp_conversation_thread_func(void *pconn) { // "close RTSP connection."); // } rtp_terminate(conn); - debug(2, "RTSP conversation thread terminated."); + debug(2, "RTSP conversation thread %d terminated.",conn->connection_number); // please_shutdown = 0; return NULL; } @@ -1979,6 +1982,7 @@ void rtsp_listen_loop(void) { if (conn == 0) die("Couldn't allocate memory for an rtsp_conn_info record."); memset(conn, 0, sizeof(rtsp_conn_info)); + conn->connection_number = RTSP_connection_index++; socklen_t slen = sizeof(conn->remote); conn->fd = accept(acceptfd, (struct sockaddr *)&conn->remote, &slen); @@ -2040,11 +2044,12 @@ void rtsp_listen_loop(void) { // conn->thread = rtsp_conversation_thread; // conn->stop = 0; // record's memory has been zeroed // conn->authorized = 0; // record's memory has been zeroed - conn->running = 1; + ret = pthread_create(&conn->thread, NULL, rtsp_conversation_thread_func, conn); // also acts as a memory barrier if (ret) - die("Failed to create RTSP receiver thread!"); + die("Failed to create RTSP receiver thread %d!",conn->connection_number); + debug(1,"Successfully created RTSP receiver thread %d.",conn->connection_number); track_thread(conn); } }