From 7334d93b30bfff22d44b8355ccc480ed7442c2d5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 6 Nov 2017 17:11:31 +0100 Subject: demux: slightly simplify pruning We can compute the overhead size easily now - no need for awkward incremental updates to cached values on top of it. --- demux/demux.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index e38f704cfb..1cd8a169bc 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -938,15 +938,11 @@ static bool read_packet(struct demux_internal *in) static void prune_old_packets(struct demux_internal *in) { - size_t buffered = in->total_bytes - in->fw_bytes; - - MP_TRACE(in, "total backbuffer = %zd\n", buffered); - // It's not clear what the ideal way to prune old packets is. For now, we // prune the oldest packet runs, as long as the total cache amount is too // big. size_t max_bytes = in->seekable_cache ? in->max_bytes_bw : 0; - while (buffered > max_bytes) { + while (in->total_bytes - in->fw_bytes > max_bytes) { double earliest_ts = MP_NOPTS_VALUE; struct demux_stream *earliest_stream = NULL; @@ -969,7 +965,7 @@ static void prune_old_packets(struct demux_internal *in) } } - assert(earliest_stream); // incorrect accounting of "buffered"? + assert(earliest_stream); // incorrect accounting of buffered sizes? struct demux_stream *ds = earliest_stream; // Prune all packets until the next keyframe or reader_head. Keeping @@ -1004,7 +1000,6 @@ static void prune_old_packets(struct demux_internal *in) struct demux_packet *dp = ds->queue->head; size_t bytes = demux_packet_estimate_total_size(dp); - buffered -= bytes; MP_TRACE(in, "dropping backbuffer packet size %zd from stream %d\n", bytes, ds->sh->index); -- cgit v1.2.3