diff options
author | wm4 <wm4@nowhere> | 2017-11-06 17:11:31 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-06 17:11:31 +0100 |
commit | 7334d93b30bfff22d44b8355ccc480ed7442c2d5 (patch) | |
tree | 43f38c0cbf0e1305e216d06d51a18f1cff95e05b | |
parent | 9e1fbffc37779c8f491d3aa8e319ab233e5ab0da (diff) | |
download | mpv-7334d93b30bfff22d44b8355ccc480ed7442c2d5.tar.bz2 mpv-7334d93b30bfff22d44b8355ccc480ed7442c2d5.tar.xz |
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.
-rw-r--r-- | demux/demux.c | 9 |
1 files changed, 2 insertions, 7 deletions
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); |