From: Mike Brady Date: Wed, 9 Jan 2019 10:09:29 +0000 (+0000) Subject: Don't use full flush to purge frames after an overrun -- flush will reset the buffers... X-Git-Tag: 3.3RC0~66^2~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34d6d89707e2cab7d08caa55e4d5722db1570a50;p=thirdparty%2Fshairport-sync.git Don't use full flush to purge frames after an overrun -- flush will reset the buffers as well. Fix a potential bug if a flush actually occurs. --- diff --git a/player.c b/player.c index ac2226d9..64aa3e56 100644 --- a/player.c +++ b/player.c @@ -856,8 +856,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { curframe = NULL; // this will be returned and will cause the loop to go around again conn->initial_reference_time = 0; conn->initial_reference_timestamp = 0; - } - if ((conn->flush_rtp_timestamp != 0) && + } else if ((conn->flush_rtp_timestamp != 0) && (modulo_32_offset(conn->flush_rtp_timestamp, curframe->given_timestamp) > conn->input_rate / 5) && (modulo_32_offset(conn->flush_rtp_timestamp, curframe->given_timestamp) < @@ -2093,8 +2092,12 @@ void *player_thread_func(void *arg) { debug(2, "Large positive sync error: %" PRId64 ".", sync_error); int64_t local_frames_to_drop = sync_error / conn->output_sample_ratio; uint32_t frames_to_drop_sized = local_frames_to_drop; - do_flush(inframe->given_timestamp + frames_to_drop_sized, - conn); // this will reset_input_flow_metrics anyway + + debug_mutex_lock(&conn->flush_mutex, 1000, 1); + conn->flush_rtp_timestamp = inframe->given_timestamp + frames_to_drop_sized; // flush all packets up to (and including?) this + reset_input_flow_metrics(conn); + debug_mutex_unlock(&conn->flush_mutex, 3); + } else if ((sync_error < 0) && ((-sync_error) > filler_length)) { debug(2, "Large negative sync error: %" PRId64 " with should_be_frame_32 of %" PRIu32