]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add index numbers for each RTSP conversation thread, to help figure debug messages...
authorMike Brady <mikebrady@eircom.net>
Mon, 21 Aug 2017 16:08:41 +0000 (18:08 +0200)
committerMike Brady <mikebrady@eircom.net>
Mon, 21 Aug 2017 16:08:41 +0000 (18:08 +0200)
player.h
rtp.c
rtsp.c

index d69792c6560b35a70705e29e3ce9cb8345cdf786..d5e67279e8333f99481ccef9c171f42296d14f24 100644 (file)
--- 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 dfd15b95c39249cc93a896b9e6362092b9dda0c4..cb1945e6dcd8b1b93b5e344d6cc2c3c4f9037e89 100644 (file)
--- 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 36d7b5ea6e161d67e5b49e748fdde765b65588bd..cb3eea05f58b3864017433355d4ef23e88446982 100644 (file)
--- 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);
     }
   }