]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
clang format
authorMike Brady <mikebrady@eircom.net>
Wed, 22 Aug 2018 12:07:04 +0000 (13:07 +0100)
committerMike Brady <mikebrady@eircom.net>
Wed, 22 Aug 2018 12:07:04 +0000 (13:07 +0100)
audio_alsa.c
player.c
rtp.c
shairport.c

index 5b4d608f42bc2e9a65262aa9f0cce9774e5fd13d..cee43e9db7e0c8f48772ab9df48d11958329b429 100644 (file)
@@ -658,7 +658,7 @@ int open_alsa_device(void) {
          snd_strerror(ret));
     return -7;
   }
-  
+
   // check parameters after attempting to set them…
 
   if (set_period_size_request != 0) {
@@ -883,12 +883,12 @@ int delay(long *the_delay) {
               snd_strerror(reply), *the_delay);
         snd_pcm_recover(alsa_handle, reply, 1);
       } else {
-        if (*the_delay==0) {
+        if (*the_delay == 0) {
           // there's nothing in the pipeline, so we can't measure frame rate.
           frame_index = 0; // we'll be starting over...
           measurement_data_is_valid = 0;
         }
-      }      
+      }
     } else {
       frame_index = 0; // we'll be starting over...
       measurement_data_is_valid = 0;
@@ -992,13 +992,13 @@ static int play(void *buf, int samples) {
                   snd_strerror(err2), fl);
             snd_pcm_recover(alsa_handle, err2, 1);
           } else {
-            if (fl==0) {
+            if (fl == 0) {
               // there's nothing in the pipeline, so we can't measure frame rate.
               frame_index = 0; // we'll be starting over...
               measurement_data_is_valid = 0;
             }
           }
-          
+
           uint64_t tf = get_absolute_time_in_fp();
           frames_played_at_measurement_time = frames_sent_for_playing - fl;
           if (frame_index == start_measurement_from_this_frame) {
index ce1056d843bf2d53f8448f88de10fbf7a345206b..bdc5ffe1375b648aedcd02841e1fd18f7591e06e 100644 (file)
--- a/player.c
+++ b/player.c
@@ -1296,7 +1296,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
       time_to_wait_for_wakeup_fp *= 4 * 352;      // four full 352-frame packets
       time_to_wait_for_wakeup_fp /= 3;            // four thirds of a packet time
 
-      time_to_wait_for_wakeup_fp = (uint64_t)0x200000000/(uint64_t)1000;            // two millisecond
+      time_to_wait_for_wakeup_fp = (uint64_t)0x200000000 / (uint64_t)1000; // two millisecond
 
 #ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
       uint64_t time_of_wakeup_fp = local_time_now + time_to_wait_for_wakeup_fp;
@@ -2106,7 +2106,7 @@ void *player_thread_func(void *arg) {
 
             int64_t should_be_frame;
             local_time_to_frame(local_time_now, &should_be_frame, conn);
-            
+
             int64_t absolute_difference_in_frames = td_in_frames + rt - should_be_frame;
             if (absolute_difference_in_frames < 0)
               absolute_difference_in_frames = -absolute_difference_in_frames;
@@ -2133,8 +2133,8 @@ void *player_thread_func(void *arg) {
                 delay - (conn->latency * conn->output_sample_ratio +
                          (int64_t)(config.audio_backend_latency_offset *
                                    config.output_rate)); // int64_t from int64_t - int32_t, so okay
-            
-            //debug(1,"%" PRId64 "",sync_error,inbuflength);
+
+            // debug(1,"%" PRId64 "",sync_error,inbuflength);
 
             // not too sure if abs() is implemented for int64_t, so we'll do it manually
             int64_t abs_sync_error = sync_error;
@@ -2195,24 +2195,25 @@ void *player_thread_func(void *arg) {
                 amount_to_stuff = 1;
               }
               */
-              
-              
-              if (amount_to_stuff==0) {
+
+              if (amount_to_stuff == 0) {
                 // use a "V" shaped function to decide if stuffing should occur
                 int64_t s = r64i();
-                s = s>>31;
+                s = s >> 31;
                 s = s * config.tolerance * config.output_rate;
-                s = (s>>32)+config.tolerance * config.output_rate; //should be a number from 0 to config.tolerance * config.output_rate;
-                if ((sync_error>0) && (sync_error>s)) {
-                  //debug(1,"Extra stuff -1");
+                s = (s >> 32) + config.tolerance * config.output_rate; // should be a number from 0
+                                                                       // to config.tolerance *
+                                                                       // config.output_rate;
+                if ((sync_error > 0) && (sync_error > s)) {
+                  // debug(1,"Extra stuff -1");
                   amount_to_stuff = -1;
                 }
-                if ((sync_error<0) && (sync_error<(-s))) {
-                  //debug(1,"Extra stuff +1");
+                if ((sync_error < 0) && (sync_error < (-s))) {
+                  // debug(1,"Extra stuff +1");
                   amount_to_stuff = 1;
-                }              
+                }
               }
-              
+
               // try to keep the corrections definitely below 1 in 1000 audio frames
 
               // calculate the time elapsed since the play session started.
@@ -2290,14 +2291,15 @@ void *player_thread_func(void *arg) {
                   tbuf32[2 * i + 1] = fbuf_r[i];
                 }
               }
-              
-              if ((current_delay < DAC_BUFFER_QUEUE_MINIMUM_LENGTH) || (config.packet_stuffing == ST_basic)) {
+
+              if ((current_delay < DAC_BUFFER_QUEUE_MINIMUM_LENGTH) ||
+                  (config.packet_stuffing == ST_basic)) {
                 play_samples =
                     stuff_buffer_basic_32((int32_t *)conn->tbuf, inbuflength, config.output_format,
-                                          conn->outbuf, amount_to_stuff, enable_dither, conn);              
+                                          conn->outbuf, amount_to_stuff, enable_dither, conn);
               }
 #ifdef HAVE_LIBSOXR
-                else if (config.packet_stuffing == ST_soxr) {
+              else if (config.packet_stuffing == ST_soxr) {
                 //                if (amount_to_stuff) debug(1,"Soxr stuff...");
                 play_samples = stuff_buffer_soxr_32((int32_t *)conn->tbuf, (int32_t *)conn->sbuf,
                                                     inbuflength, config.output_format, conn->outbuf,
@@ -2451,10 +2453,10 @@ void *player_thread_func(void *arg) {
               conn->frame_rate =
                   (1.0 * frames_played) /
                   elapsed_play_time; // an IEEE double calculation with two 64-bit integers
-              conn->frame_rate = conn->frame_rate *
-                                 (uint64_t)0x100000000; // this should just change the [binary]
-                                                        // exponent in the IEEE FP representation;
-                                                        // the mantissa should be unaffected.
+              conn->frame_rate =
+                  conn->frame_rate * (uint64_t)0x100000000; // this should just change the [binary]
+              // exponent in the IEEE FP representation;
+              // the mantissa should be unaffected.
             } else {
               conn->frame_rate = 0.0;
             }
@@ -2473,96 +2475,86 @@ void *player_thread_func(void *arg) {
 
               if ((config.output->delay)) {
                 if (config.no_sync == 0) {
-                  inform("%*.2f," /* Sync error in milliseconds */
-                         "%*.1f," /* net correction in ppm */
-                         "%*.1f," /* corrections in ppm */
-                         "%*d,"   /* total packets */
+                  inform("%*.2f,"        /* Sync error in milliseconds */
+                         "%*.1f,"        /* net correction in ppm */
+                         "%*.1f,"        /* corrections in ppm */
+                         "%*d,"          /* total packets */
                          "%*" PRIu64 "," /* missing packets */
                          "%*" PRIu64 "," /* late packets */
                          "%*" PRIu64 "," /* too late packets */
                          "%*" PRIu64 "," /* resend requests */
                          "%*" PRId64 "," /* min DAC queue size */
-                         "%*" PRId32 ","   /* min buffer occupancy */
-                         "%*" PRId32 ","   /* max buffer occupancy */
-                         "%*.2f,"  /* source nominal frame rate */
-                         "%*.2f,"  /* source actual (average) frame rate */
-                         "%*.2f,"  /* output frame rate */
-                         "%*.2f,"  /* source clock drift */
-                         "%*d,"    /* source clock drift sample count */
-                         "%*.2f", /* rough calculated correction in ppm */
-                         10, 1000 * moving_average_sync_error / config.output_rate,
-                         10, moving_average_correction * 1000000 / (352 * conn->output_sample_ratio),
+                         "%*" PRId32 "," /* min buffer occupancy */
+                         "%*" PRId32 "," /* max buffer occupancy */
+                         "%*.2f,"        /* source nominal frame rate */
+                         "%*.2f,"        /* source actual (average) frame rate */
+                         "%*.2f,"        /* output frame rate */
+                         "%*.2f,"        /* source clock drift */
+                         "%*d,"          /* source clock drift sample count */
+                         "%*.2f",        /* rough calculated correction in ppm */
+                         10,
+                         1000 * moving_average_sync_error / config.output_rate, 10,
+                         moving_average_correction * 1000000 / (352 * conn->output_sample_ratio),
                          10, moving_average_insertions_plus_deletions * 1000000 /
                                  (352 * conn->output_sample_ratio),
-                         12, play_number,
-                         7, conn->missing_packets,
-                         7, conn->late_packets,
-                         7, conn->too_late_packets,
-                         7, conn->resend_requests,
-                         7, minimum_dac_queue_size,
-                         5, minimum_buffer_occupancy,
-                         5, maximum_buffer_occupancy,
-                         11, conn->remote_frame_rate,
-                         11, conn->input_frame_rate,
-                         11, conn->frame_rate,
-                         10, (conn->local_to_remote_time_gradient-1.0) * 1000000,
-                         6, conn->local_to_remote_time_gradient_sample_count,
-                         10, (conn->frame_rate > 0.0) ? ((conn->frame_rate - conn->remote_frame_rate * conn->output_sample_ratio * conn->local_to_remote_time_gradient)*1000000)/conn->frame_rate : 0.0);
+                         12, play_number, 7, conn->missing_packets, 7, conn->late_packets, 7,
+                         conn->too_late_packets, 7, conn->resend_requests, 7,
+                         minimum_dac_queue_size, 5, minimum_buffer_occupancy, 5,
+                         maximum_buffer_occupancy, 11, conn->remote_frame_rate, 11,
+                         conn->input_frame_rate, 11, conn->frame_rate, 10,
+                         (conn->local_to_remote_time_gradient - 1.0) * 1000000, 6,
+                         conn->local_to_remote_time_gradient_sample_count, 10,
+                         (conn->frame_rate > 0.0)
+                             ? ((conn->frame_rate -
+                                 conn->remote_frame_rate * conn->output_sample_ratio *
+                                     conn->local_to_remote_time_gradient) *
+                                1000000) /
+                                   conn->frame_rate
+                             : 0.0);
                 } else {
-                  inform("%*.2f," /* Sync error in milliseconds */
-                         "%*d,"   /* total packets */
+                  inform("%*.2f,"        /* Sync error in milliseconds */
+                         "%*d,"          /* total packets */
                          "%*" PRIu64 "," /* missing packets */
                          "%*" PRIu64 "," /* late packets */
                          "%*" PRIu64 "," /* too late packets */
                          "%*" PRIu64 "," /* resend requests */
                          "%*" PRId64 "," /* min DAC queue size */
-                         "%*" PRId32 ","   /* min buffer occupancy */
-                         "%*" PRId32 ","   /* max buffer occupancy */
-                         "%*.2f," /* source nominal frame rate */
-                         "%*.2f," /* source actual (average) frame rate */
-                         "%*.2f," /* source clock drift */
-                         "%*d",   /* source clock drift sample count */
+                         "%*" PRId32 "," /* min buffer occupancy */
+                         "%*" PRId32 "," /* max buffer occupancy */
+                         "%*.2f,"        /* source nominal frame rate */
+                         "%*.2f,"        /* source actual (average) frame rate */
+                         "%*.2f,"        /* source clock drift */
+                         "%*d",          /* source clock drift sample count */
                          10,
-                         1000 * moving_average_sync_error / config.output_rate,
-                         12, play_number,
-                         7, conn->missing_packets,
-                         7, conn->late_packets,
-                         7, conn->too_late_packets,
-                         7, conn->resend_requests,
-                         7, minimum_dac_queue_size,
-                         5, minimum_buffer_occupancy,
-                         5, maximum_buffer_occupancy,
-                         11, conn->remote_frame_rate,
-                         11, conn->input_frame_rate,
-                         10, (conn->local_to_remote_time_gradient-1.0) * 1000000,
-                         6, conn->local_to_remote_time_gradient_sample_count);
+                         1000 * moving_average_sync_error / config.output_rate, 12, play_number, 7,
+                         conn->missing_packets, 7, conn->late_packets, 7, conn->too_late_packets, 7,
+                         conn->resend_requests, 7, minimum_dac_queue_size, 5,
+                         minimum_buffer_occupancy, 5, maximum_buffer_occupancy, 11,
+                         conn->remote_frame_rate, 11, conn->input_frame_rate, 10,
+                         (conn->local_to_remote_time_gradient - 1.0) * 1000000, 6,
+                         conn->local_to_remote_time_gradient_sample_count);
                 }
               } else {
-                inform("%*.2f," /* Sync error in milliseconds */
-                       "%*d,"   /* total packets */
+                inform("%*.2f,"        /* Sync error in milliseconds */
+                       "%*d,"          /* total packets */
                        "%*" PRIu64 "," /* missing packets */
                        "%*" PRIu64 "," /* late packets */
                        "%*" PRIu64 "," /* too late packets */
                        "%*" PRIu64 "," /* resend requests */
-                       "%*" PRId32 ","   /* min buffer occupancy */
-                       "%*" PRId32 ","   /* max buffer occupancy */
-                       "%*.2f," /* source nominal frame rate */
-                       "%*.2f," /* source actual (average) frame rate */
-                       "%*.2f," /* source clock drift */
-                       "%*d",   /* source clock drift sample count */
+                       "%*" PRId32 "," /* min buffer occupancy */
+                       "%*" PRId32 "," /* max buffer occupancy */
+                       "%*.2f,"        /* source nominal frame rate */
+                       "%*.2f,"        /* source actual (average) frame rate */
+                       "%*.2f,"        /* source clock drift */
+                       "%*d",          /* source clock drift sample count */
                        10,
-                       1000 * moving_average_sync_error / config.output_rate,
-                       12, play_number,
-                       7, conn->missing_packets,
-                       7, conn->late_packets,
-                       7, conn->too_late_packets,
-                       7, conn->resend_requests,
-                       5, minimum_buffer_occupancy,
-                       5, maximum_buffer_occupancy,
-                       11, conn->remote_frame_rate,
-                       11, conn->input_frame_rate,
-                       10, (conn->local_to_remote_time_gradient-1.0) * 1000000,
-                       6, conn->local_to_remote_time_gradient_sample_count);
+                       1000 * moving_average_sync_error / config.output_rate, 12, play_number, 7,
+                       conn->missing_packets, 7, conn->late_packets, 7, conn->too_late_packets, 7,
+                       conn->resend_requests, 5, minimum_buffer_occupancy, 5,
+                       maximum_buffer_occupancy, 11, conn->remote_frame_rate, 11,
+                       conn->input_frame_rate, 10,
+                       (conn->local_to_remote_time_gradient - 1.0) * 1000000, 6,
+                       conn->local_to_remote_time_gradient_sample_count);
               }
             } else {
               inform("No frames received in the last sampling interval.");
diff --git a/rtp.c b/rtp.c
index 41d1747d1d0bdb7c54a276752c183fd7b3e7309b..c13c3d258a3ecf9142bc763d3c0695c1c718f719 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -797,7 +797,8 @@ void *rtp_timing_receiver(void *arg) {
             } else {
               conn->local_to_remote_time_gradient = 1.0;
             }
-            // debug(1,"local to remote time gradient is %12.2f ppm, based on %d samples.",conn->local_to_remote_time_gradient*1000000,sample_count);
+            // debug(1,"local to remote time gradient is %12.2f ppm, based on %d
+            // samples.",conn->local_to_remote_time_gradient*1000000,sample_count);
           } else {
             debug(2, "Time ping turnaround time: %lld us -- it looks like a timing ping was lost.",
                   (return_time * 1000000) >> 32);
index 057d4ed059b3dff8c0ffd5824ac86178b1e133f4..bd4025dc3efafbe11ad9728755ede9b3b8d7c447 100644 (file)
 #include <libconfig.h>
 #include <libgen.h>
 #include <memory.h>
-#include <sys/socket.h>
 #include <net/if.h>
 #include <popt.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>