From b782c901809a47dddadc33368d66d88d1bd9e9b9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Dec 2017 05:07:36 +0100 Subject: demux_timeline: disable pointless packet cache for sub-demuxers It seems like there's nothing stopping from sub-demuxers from keeping packets in the cache, even if it's completely pointless. The top-most demuxer (demux_timeline) already takes care of caching, so sub-demuxers only waste space and time with this. Add a function that can disable the packet cache even at runtime and after packets are read. (It's not clear whether it really can happen that packets are read before demux_timeline gets the sub-demuxers, but there's no reason to make it too fragile.) Call it on all sub-demuxers. For this to work, it seems we have to move the code for setting the seekable_cache flag to before demux_timeline is potentially initialized, because otherwise the cache would be reenabled if the demuxer triggering timeline support is a timeline segment itself (e.g. ordered chapters). --- demux/demux_timeline.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'demux/demux_timeline.c') diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index 288e9f750a..4b9b3124fa 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -170,6 +170,8 @@ static void reopen_lazy_segments(struct demuxer *demuxer) demuxer->stream->cancel, demuxer->global); if (!p->current->d && !demux_cancel_test(demuxer)) MP_ERR(demuxer, "failed to load segment\n"); + if (p->current->d) + demux_disable_cache(p->current->d); associate_streams(demuxer, p->current); } @@ -385,6 +387,11 @@ static int d_open(struct demuxer *demuxer, enum demux_check check) struct timeline_part *part = &p->tl->parts[n]; struct timeline_part *next = &p->tl->parts[n + 1]; + // demux_timeline already does caching, doing it for the sub-demuxers + // would be pointless and wasteful. + if (part->source) + demux_disable_cache(part->source); + struct segment *seg = talloc_ptrtype(p, seg); *seg = (struct segment){ .d = part->source, -- cgit v1.2.3