From: Mike Brady Date: Tue, 15 May 2018 08:11:50 +0000 (+0100) Subject: Allow a great number of buffers and parameterise the fixed latency limits. X-Git-Tag: 3.2RC8~2^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=431586726db796051816c0230e2f4823a146bc4e;p=thirdparty%2Fshairport-sync.git Allow a great number of buffers and parameterise the fixed latency limits. --- diff --git a/player.c b/player.c index 2ce2c349..046fded6 100644 --- 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++; diff --git a/shairport.c b/shairport.c index fcb7629c..30dc9d65 100644 --- a/shairport.c +++ b/shairport.c @@ -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 */