]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Reduce the rate at which resends are requests to make them less, uh, insistent
authorMike Brady <mikebrady@eircom.net>
Fri, 29 Jun 2018 21:59:19 +0000 (22:59 +0100)
committerMike Brady <mikebrady@eircom.net>
Fri, 29 Jun 2018 21:59:19 +0000 (22:59 +0100)
player.c

index 3a2b8dc02494752d9f078a6f9446b1d9495b1f08..f713dce8fef7540392d6f9a6bdd7cf801ebbc101 100644 (file)
--- a/player.c
+++ b/player.c
@@ -607,10 +607,11 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp
             int j;
             for (j = 1; j <= number_of_resend_attempts; j++) {
               // check j times, after a short period of has elapsed, assuming 352 frames per packet
-
-              int back_step = resend_interval * j;
+              // the higher the step_exponent, the less it will try. 1 means it will try very hard. 2.0 seems good.
+              float step_exponent = 2.0;
+              int back_step = (int)(resend_interval * pow(j,step_exponent));
               int k;
-              for (k = -2; k <= 2; k++) {
+              for (k = -1; k <= 1; k++) {
                 if ((back_step + k) <
                     seq_diff(conn->ab_read, conn->ab_write,
                              conn->ab_read)) { // if it's within the range of frames in use...
@@ -622,7 +623,7 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp
                        j)) { // prevent multiple requests from the same level of lookback
                     check_buf->resend_level = j;
                     if (config.disable_resend_requests == 0) {
-                      if ((back_step + k + resend_interval) >=
+                      if (((int)(resend_interval * pow(j+1,step_exponent)) + k) >=
                           seq_diff(conn->ab_read, conn->ab_write, conn->ab_read))
                         debug(3, "Last-ditch (#%d) resend request for packet %u in range %u to %u. "
                                  "Looking back %d packets.",