]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Allow a great number of buffers and parameterise the fixed latency limits.
authorMike Brady <mikebrady@eircom.net>
Tue, 15 May 2018 08:11:50 +0000 (09:11 +0100)
committerMike Brady <mikebrady@eircom.net>
Tue, 15 May 2018 08:11:50 +0000 (09:11 +0100)
player.c
shairport.c

index 2ce2c34963c2e6f488d43e5c85800b56249259be..046fded6a534989914e9341f26e08b8ebf7c61c9 100644 (file)
--- a/player.c
+++ b/player.c
@@ -512,11 +512,19 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp
         }
 
         // here, we should check for missing frames
+        const int number_of_resend_attempts = 8;
         if (!conn->ab_buffering) {
           int j;
-          for (j = 1; j <= 8; 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 = (((250 * 44100) / 352) / 1000) * (j); // approx 250 ms intervals
+            // int back_step = (((250 * 44100) / 352) / 1000) * (j); // approx 250 ms intervals
+            // int back_step = ((BUFFER_FRAMES-(22050/352)) / number_of_resend_attempts) * j;
+            int back_step = ((seq_diff(conn->ab_read, conn->ab_write,
+                           conn->ab_read)-(22050/352)) / number_of_resend_attempts) * j;
+            if (back_step<(((190 * 44100) / 352) / 1000) * j) {
+              // debug(1,"resend request back_step %d is too small. Reset to %d.",back_step,(((190 * 44100) / 352) / 1000) * j);
+              back_step = (((190 * 44100) / 352) / 1000) * j;
+            }
             int k;
             for (k = -2; k <= 2; k++) {
               if (back_step <
@@ -1217,9 +1225,6 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
 
   // seq_t read = conn->ab_read;
 
-  // check if t+8, t+16, t+32, t+64, t+128, ... (buffer_start_fill / 2)
-  // packets have arrived... last-chance resend
-
   if (!curframe->ready) {
     // debug(1, "Supplying a silent frame for frame %u", read);
     conn->missing_packets++;
index fcb7629c248c1fa63f5e1cd99593bdf71e380af6..30dc9d6523c3cea4d08376eaff65ff12a85086fe 100644 (file)
@@ -1362,8 +1362,8 @@ int main(int argc, char **argv) {
            "latency from the source.");
     inform("Please remove this setting and use the relevant audio_backend_latency_offset setting, "
            "if necessary, to compensate for delays elsewhere.");
-    if ((config.userSuppliedLatency!=0) && ((config.userSuppliedLatency<4410) || (config.userSuppliedLatency>154350)))
-      die("An out-of-range fixed latency has been specified. It must be between 4,410 and 154,350.");
+    if ((config.userSuppliedLatency!=0) && ((config.userSuppliedLatency<4410) || (config.userSuppliedLatency>BUFFER_FRAMES*352-22050)))
+      die("An out-of-range fixed latency has been specified. It must be between 4410 and %d (at 44100 frames per second).",BUFFER_FRAMES*352-22050);
   }
 
   /* print out version */