]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
clang-format
authorMike Brady <mikebrady@eircom.net>
Sat, 24 Nov 2018 11:16:57 +0000 (11:16 +0000)
committerMike Brady <mikebrady@eircom.net>
Sat, 24 Nov 2018 11:16:57 +0000 (11:16 +0000)
common.c
player.c
rtp.c
rtsp.c

index bf062eddd79f15411fc8203b434998af3c5f3c68..0d76a4f42f6439b989a5522165be62806eb6f49f 100644 (file)
--- a/common.c
+++ b/common.c
@@ -96,18 +96,16 @@ sigset_t pselect_sigset;
 
 static uint16_t UDPPortIndex = 0;
 
-void resetFreeUDPPort() {
-       UDPPortIndex = 0;
-}
+void resetFreeUDPPort() { UDPPortIndex = 0; }
 
-uint16_t nextFreeUDPPort() {   
-       if (UDPPortIndex == 0)
-               UDPPortIndex = config.udp_port_base;
-       else if (UDPPortIndex == (config.udp_port_base + config.udp_port_range - 1))
-               UDPPortIndex = config.udp_port_base;
-       else
-               UDPPortIndex++;
-       return UDPPortIndex;
+uint16_t nextFreeUDPPort() {
+  if (UDPPortIndex == 0)
+    UDPPortIndex = config.udp_port_base;
+  else if (UDPPortIndex == (config.udp_port_base + config.udp_port_range - 1))
+    UDPPortIndex = config.udp_port_base;
+  else
+    UDPPortIndex++;
+  return UDPPortIndex;
 }
 
 int get_requested_connection_state_to_output() { return requested_connection_state_to_output; }
index dcd2a93e45d4cc23a2df4b25dba720e725bf6e13..8211c8dcea0d87f132ee625ebd332d8bbae0415c 100644 (file)
--- a/player.c
+++ b/player.c
@@ -464,15 +464,16 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, uint8_t *data, in
       conn->initial_reference_time = 0;
       conn->initial_reference_timestamp = 0;
     } else {
-    /*
-      if ((conn->flush_rtp_timestamp != 0) &&
-          (modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) > conn->input_rate / 5) &&
-          (modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) < conn->input_rate)) {
-        // between 0.2 and 1 second
-        debug(2, "Dropping flush request in player_put_packet");
-        conn->flush_rtp_timestamp = 0;
-      }
-    */
+      /*
+        if ((conn->flush_rtp_timestamp != 0) &&
+            (modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) > conn->input_rate / 5)
+        &&
+            (modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) < conn->input_rate)) {
+          // between 0.2 and 1 second
+          debug(2, "Dropping flush request in player_put_packet");
+          conn->flush_rtp_timestamp = 0;
+        }
+      */
 
       abuf_t *abuf = 0;
 
@@ -851,10 +852,11 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
             debug(1, "Inconsistent sequence numbers detected");
           }
         }
-        
-        //if (conn->flush_rtp_timestamp != 0)
-        //  debug(2,"flush_rtp_timestamp is %" PRIx32 " and curframe->given_timestamp is %" PRIx32 ".", conn->flush_rtp_timestamp , curframe->given_timestamp);
-        
+
+        // if (conn->flush_rtp_timestamp != 0)
+        //  debug(2,"flush_rtp_timestamp is %" PRIx32 " and curframe->given_timestamp is %" PRIx32
+        //  ".", conn->flush_rtp_timestamp , curframe->given_timestamp);
+
         if ((conn->flush_rtp_timestamp != 0) &&
             (curframe->given_timestamp != conn->flush_rtp_timestamp) &&
             (modulo_32_offset(curframe->given_timestamp, conn->flush_rtp_timestamp) <
@@ -953,11 +955,9 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
               if (local_time_now > conn->first_packet_time_to_play) {
                 uint64_t lateness = local_time_now - conn->first_packet_time_to_play;
                 lateness = (lateness * 1000000) >> 32; // microseconds
-                debug(
-                    3,
-                    "First packet is %" PRIu64 " microseconds late! Flushing 0.5 seconds",lateness);
-                do_flush(conn->first_packet_timestamp + 5 * 4410,
-                             conn);
+                debug(3, "First packet is %" PRIu64 " microseconds late! Flushing 0.5 seconds",
+                      lateness);
+                do_flush(conn->first_packet_timestamp + 5 * 4410, conn);
               }
             }
           }
@@ -988,7 +988,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
             if (local_time_now > conn->first_packet_time_to_play) {
               uint64_t lateness = local_time_now - conn->first_packet_time_to_play;
               lateness = (lateness * 1000000) >> 32; // microseconds
-              debug(3,"Gone past starting time by %" PRIu64 " microseconds.", lateness);
+              debug(3, "Gone past starting time by %" PRIu64 " microseconds.", lateness);
               have_sent_prefiller_silence = 1;
               conn->ab_buffering = 0;
 
@@ -2476,8 +2476,8 @@ void *player_thread_func(void *arg) {
 
   debug(1, "This should never be called.");
   pthread_cleanup_pop(1); // pop the cleanup handler
-//  debug(1, "This should never be called either.");
-//  pthread_cleanup_pop(1); // pop the initial cleanup handler
+                          //  debug(1, "This should never be called either.");
+                          //  pthread_cleanup_pop(1); // pop the initial cleanup handler
   pthread_exit(NULL);
 }
 
@@ -2776,7 +2776,7 @@ int player_play(rtsp_conn_info *conn) {
 
 int player_stop(rtsp_conn_info *conn) {
   // note -- this may be called from another connection thread.
-  //int dl = debuglev;
+  // int dl = debuglev;
   // debuglev = 3;
   debug(3, "player_stop");
   if (conn->player_thread) {
diff --git a/rtp.c b/rtp.c
index 4e5a98d6fd659bd21788eab6b4cd5d703b8adb0a..0c97fc31a25541f100006d50be35930c97ff69fa 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -104,7 +104,7 @@ void rtp_audio_receiver_cleanup_handler(void *arg) {
   shutdown(conn->audio_socket, SHUT_RDWR);
   debug(3, "close audio socket.");
   close(conn->audio_socket);
-  
+
   debug(3, "Audio Receiver Cleanup Successful.");
 }
 
@@ -170,8 +170,8 @@ void *rtp_audio_receiver(void *arg) {
         // increment last_seqno and see if it's the same as the incoming seqno
 
         if (type == 0x60) { // regular audio data
-        
-          /*      
+
+          /*
           char obf[4096];
           char *obfp = obf;
           int obfc;
@@ -181,8 +181,8 @@ void *rtp_audio_receiver(void *arg) {
           };
           *obfp=0;
           debug(1,"Audio Packet Received: \"%s\"",obf);
-          */        
-        
+          */
+
           if (last_seqno == -1)
             last_seqno = seqno;
           else {
@@ -196,7 +196,7 @@ void *rtp_audio_receiver(void *arg) {
         }
 
         uint32_t actual_timestamp = ntohl(*(uint32_t *)(pktp + 4));
-        
+
         // uint32_t ssid = ntohl(*(uint32_t *)(pktp + 8));
         // debug(1, "Audio packet SSID: %08X,%u", ssid,ssid);
 
@@ -308,8 +308,10 @@ void *rtp_control_receiver(void *arg) {
                                              
                                                               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 " respectively.",monotonic_timestamp(rt, conn),monotonic_timestamp(rtlt, conn));
+                                                              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 "
+                                                          respectively.",monotonic_timestamp(rt, conn),monotonic_timestamp(rtlt, conn));
                                                             }
                                                        */
           if (conn->local_to_remote_time_difference) { // need a time packet to be interchanged
@@ -860,8 +862,8 @@ static uint16_t bind_port(int ip_family, const char *self_ip_address, uint32_t s
   int tryCount = 0;
   uint16_t desired_port;
   do {
-       tryCount++;
-         desired_port = nextFreeUDPPort();
+    tryCount++;
+    desired_port = nextFreeUDPPort();
     memset(&myaddr, 0, sizeof(myaddr));
     if (ip_family == AF_INET) {
       struct sockaddr_in *sa = (struct sockaddr_in *)&myaddr;
@@ -888,7 +890,8 @@ static uint16_t bind_port(int ip_family, const char *self_ip_address, uint32_t s
 
   if (ret < 0) {
     close(local_socket);
-    die("error: could not bind a UDP port! Check the udp_port_range is large enough -- it must be at least 3, and 10 or more is suggested -- or "
+    die("error: could not bind a UDP port! Check the udp_port_range is large enough -- it must be "
+        "at least 3, and 10 or more is suggested -- or "
         "check for restrictive firewall settings or a bad router!");
   }
 
diff --git a/rtsp.c b/rtsp.c
index cd46598edccf6928c2da53b93a89cd460a2145f0..99000174356c77b50c0e2c2b0cd310299db6f5f1 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -543,7 +543,8 @@ enum rtsp_read_request_response rtsp_read_request(rtsp_conn_info *conn, rtsp_mes
         continue;
       char errorstring[1024];
       strerror_r(errno, (char *)errorstring, sizeof(errorstring));
-      debug(1, "Connection %d: rtsp_read_request_response_read_error %d: \"%s\".", conn->connection_number, errno, (char *)errorstring);
+      debug(1, "Connection %d: rtsp_read_request_response_read_error %d: \"%s\".",
+            conn->connection_number, errno, (char *)errorstring);
       reply = rtsp_read_request_response_read_error;
       goto shutdown;
     }
@@ -896,7 +897,7 @@ void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
 error:
   warn("Connection %d: SETUP -- Error in setup request -- unlocking play lock.",
        conn->connection_number);
-  debug_mutex_lock(&playing_conn_lock, 1000000 , 3);
+  debug_mutex_lock(&playing_conn_lock, 1000000, 3);
   playing_conn = NULL; // this connection definitely doesn't have the play lock
   debug_mutex_unlock(&playing_conn_lock, 3);
   resp->respcode = 451; // invalid arguments
@@ -1522,40 +1523,40 @@ static void handle_set_parameter(rtsp_conn_info *conn, rtsp_message *req, rtsp_m
 
 static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
   debug(2, "Connection %d: ANNOUNCE", conn->connection_number);
-  
-  
+
   int have_the_player = 0;
   int should_wait = 0; // this will be true if you're trying to break in to the current session
   int interrupting_current_session = 0;
-  
+
   // try to become the current playing_conn
-  
-  debug_mutex_lock(&playing_conn_lock, 1000000 , 3); //get it
-  
+
+  debug_mutex_lock(&playing_conn_lock, 1000000, 3); // get it
+
   if (playing_conn == NULL) {
     playing_conn = conn;
     have_the_player = 1;
   } else if (playing_conn == conn) {
-      have_the_player = 1;
-      warn("Duplicate ANNOUNCE, by the look of it!");
+    have_the_player = 1;
+    warn("Duplicate ANNOUNCE, by the look of it!");
   } else if (playing_conn->stop) {
-      debug(2, "Connection %d: ANNOUNCE: already shutting down; waiting for it...",playing_conn->connection_number);
-      should_wait = 1;
+    debug(2, "Connection %d: ANNOUNCE: already shutting down; waiting for it...",
+          playing_conn->connection_number);
+    should_wait = 1;
   } else if (config.allow_session_interruption == 1) {
     debug(2, "Connection %d: ANNOUNCE: asking playing connection %d to shut down.",
-            conn->connection_number, playing_conn->connection_number);
+          conn->connection_number, playing_conn->connection_number);
     playing_conn->stop = 1;
     interrupting_current_session = 1;
-    should_wait = 1;    
+    should_wait = 1;
     pthread_cancel(playing_conn->thread); // asking the RTSP thread to exit
-  } 
+  }
   debug_mutex_unlock(&playing_conn_lock, 3);
 
   if (should_wait) {
     useconds_t time_remaining = 3000000;
-      
+
     while ((time_remaining > 0) && (have_the_player == 0)) {
-      debug_mutex_lock(&playing_conn_lock, 1000000 , 3); //get it
+      debug_mutex_lock(&playing_conn_lock, 1000000, 3); // get it
       if (playing_conn == NULL) {
         playing_conn = conn;
         have_the_player = 1;
@@ -1563,10 +1564,10 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
       debug_mutex_unlock(&playing_conn_lock, 3);
 
       if (have_the_player == 0) {
-          usleep(100000);
-          time_remaining -= 100000;
-        }
+        usleep(100000);
+        time_remaining -= 100000;
       }
+    }
 
     if ((have_the_player == 1) && (interrupting_current_session == 1)) {
       debug(2, "Connection %d: ANNOUNCE got the player", conn->connection_number);
@@ -1577,14 +1578,14 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
 
   if (have_the_player) {
     debug(3, "RTSP conversation thread %d has acquired play lock.", conn->connection_number);
-    
+
     // now, if this new session did not break in, then it's okay to reset the next UDP ports
     // to the start of the range
-    
+
     if (interrupting_current_session == 0) { // will be zero if it wasn't waiting to break in
-       resetFreeUDPPort();
+      resetFreeUDPPort();
     }
-    
+
     /*
     {
       char *cp = req->content;
@@ -1597,8 +1598,7 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
       }
     }
 */
-    
-    
+
     resp->respcode = 456; // 456 - Header Field Not Valid for Resource
     char *pssid = NULL;
     char *paesiv = NULL;
@@ -1643,11 +1643,11 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag
 
       cp = next;
     }
-    
+
     if (pssid) {
       uint32_t ssid = uatoi(pssid);
-      debug(3, "Synchronisation Source Identifier: %08X,%u", ssid,ssid);
-    }    
+      debug(3, "Synchronisation Source Identifier: %08X,%u", ssid, ssid);
+    }
 
     if (pminlatency) {
       conn->minimum_latency = atoi(pminlatency);
@@ -1751,7 +1751,7 @@ out:
   if (resp->respcode != 200 && resp->respcode != 453) {
     debug(1, "Connection %d: Error in handling ANNOUNCE. Unlocking the play lock.",
           conn->connection_number);
-    debug_mutex_lock(&playing_conn_lock, 1000000 , 3); //get it
+    debug_mutex_lock(&playing_conn_lock, 1000000, 3); // get it
     playing_conn = NULL;
     debug_mutex_unlock(&playing_conn_lock, 3);
   }
@@ -2007,7 +2007,7 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
     conn->auth_nonce = NULL;
   }
   rtp_terminate(conn);
-  
+
   if (conn->dacp_id) {
     free(conn->dacp_id);
     conn->dacp_id = NULL;
@@ -2025,7 +2025,7 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
   if (rc)
     debug(1, "Connection %d: error %d destroying flush_mutex.", conn->connection_number, rc);
 
-  debug_mutex_lock(&playing_conn_lock, 1000000 , 3); //get it
+  debug_mutex_lock(&playing_conn_lock, 1000000, 3); // get it
   if (playing_conn == conn) {
     debug(3, "Connection %d: Unlocking play lock.", conn->connection_number);
     playing_conn = NULL;
@@ -2141,7 +2141,9 @@ static void *rtsp_conversation_thread_func(void *pconn) {
       if (conn->stop == 0) {
         int err = msg_write_response(conn->fd, resp);
         if (err) {
-          debug(1, "Connection %d: Unable to write an RTSP message response. Terminating the connection.", conn->connection_number);
+          debug(1, "Connection %d: Unable to write an RTSP message response. Terminating the "
+                   "connection.",
+                conn->connection_number);
           conn->stop = 1;
         }
       }
@@ -2161,7 +2163,8 @@ static void *rtsp_conversation_thread_func(void *pconn) {
             // debuglev = 3; // see what happens next
           } else {
             if (reply == rtsp_read_request_response_channel_closed)
-              debug(2, "Connection %d: RTSP channel unexpectedly closed -- will try again %d time(s).",
+              debug(2,
+                    "Connection %d: RTSP channel unexpectedly closed -- will try again %d time(s).",
                     conn->connection_number, rtsp_read_request_attempt_count);
             if (reply == rtsp_read_request_response_read_error)
               debug(2, "Connection %d: RTSP channel read error -- will try again %d time(s).",
@@ -2172,7 +2175,8 @@ static void *rtsp_conversation_thread_func(void *pconn) {
           tstop = 1;
         }
       } else {
-        debug(1, "Connection %d: rtsp_read_request error %d, packet ignored.", conn->connection_number, (int)reply);
+        debug(1, "Connection %d: rtsp_read_request error %d, packet ignored.",
+              conn->connection_number, (int)reply);
       }
       if (tstop) {
         debug(3, "Connection %d: Terminate RTSP connection.", conn->connection_number);