Skip to content

Commit 52525dc

Browse files
committed
demux: clear packet pool when upper memory limit is lowered
This clears packets from the pool, that would never be reused under new settings. Note that depending on demuxer state this clears only unused packets, in some cases demuxer may still hold more packets than the new limit. Fox example demuxer doesn't forcefully clear forward cache when reducing the size. Also keep packet pool, even if current file is not cached, this is useful for all sorts of things and may be useful for next file. This act only on user options values, regardless of internal demuxer caching state, which can vary depending on track type or source.
1 parent e6885cb commit 52525dc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

demux/demux.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2519,8 +2519,14 @@ static void update_opts(struct demuxer *demuxer)
25192519
// Make demuxing progress. Return whether progress was made.
25202520
static bool thread_work(struct demux_internal *in)
25212521
{
2522-
if (m_config_cache_update(in->d_user->opts_cache))
2522+
struct demux_opts *opts = in->d_user->opts;
2523+
size_t old_max_bytes = opts->max_bytes;
2524+
size_t old_max_bytes_bw = opts->max_bytes_bw;
2525+
if (m_config_cache_update(in->d_user->opts_cache)) {
25232526
update_opts(in->d_user);
2527+
if (opts->max_bytes + opts->max_bytes_bw < old_max_bytes + old_max_bytes_bw)
2528+
demux_packet_pool_clear(in->packet_pool);
2529+
}
25242530
if (in->tracks_switched) {
25252531
execute_trackswitch(in);
25262532
return true;

0 commit comments

Comments
 (0)