mpv/player
wm4 17da9071a4 demux: add a on-disk cache
Somewhat similar to the old --cache-file, except for the demuxer cache.
Instead of keeping packet data in memory, it's written to disk and read
back when needed.

The idea is to reduce main memory usage, while allowing fast seeking in
large cached network streams (especially live streams). Keeping the
packet metadata on disk would be rather hard (would use mmap or so, or
rewrite the entire demux.c packet queue handling), and since it's
relatively small, just keep it in memory.

Also for simplicity, the disk cache is append-only. If you're watching
really long livestreams, and need pruning, you're probably out of luck.
This still could be improved by trying to free unused blocks with
fallocate(), but since we're writing multiple streams in an interleaved
manner, this is slightly hard.

Some rather gross ugliness in packet.h: we want to store the file
position of the cached data somewhere, but on 32 bit architectures, we
don't have any usable 64 bit members for this, just the buf/len fields,
which add up to 64 bit - so the shitty union aliases this memory.

Error paths untested. Side data (the complicated part of trying to
serialize ffmpeg packets) untested.

Stream recording had to be adjusted. Some minor details change due to
this, but probably nothing important.

The change in attempt_range_joining() is because packets in cache
have no valid len field. It was a useful check (heuristically
finding broken cases), but not a necessary one.

Various other approaches were tried. It would be interesting to list
them and to mention the pros and cons, but I don't feel like it.
2019-09-19 20:37:05 +02:00
..
javascript js: expose mpv_abort_async_command() (match dbe831bd) 2019-09-11 21:08:04 +03:00
lua demux_edl, cue, mkv: clean up timeline stuff slightly 2019-09-19 20:37:04 +02:00
audio.c player: ensure backward playback state is propagated on track switching 2019-09-19 20:37:05 +02:00
client.c client: fix potential mpv_cmd/async leak 2019-07-08 16:42:47 +02:00
client.h command: add infrastructure for async commands 2018-05-24 19:56:34 +02:00
command.c demux: add a on-disk cache 2019-09-19 20:37:05 +02:00
command.h command: add a way to abort asynchronous commands 2018-05-24 19:56:34 +02:00
configfiles.c Remove optical disc fancification layers 2019-09-13 17:31:59 +02:00
core.h player: fix --loop with backward playback 2019-09-19 20:37:05 +02:00
external_files.c external_files: add .lrc subtitle extension 2019-09-02 01:25:43 +03:00
external_files.h player: get rid of mpv_global.opts 2018-05-24 19:56:35 +02:00
javascript.c js: expose mpv_abort_async_command() (match dbe831bd) 2019-09-11 21:08:04 +03:00
loadfile.c demux: redo timed metadata 2019-09-19 20:37:05 +02:00
lua.c lua: expose mpv_abort_async_command() 2018-05-24 19:56:34 +02:00
main.c Implement backwards playback 2019-09-19 20:37:04 +02:00
misc.c player: fix --loop with backward playback 2019-09-19 20:37:05 +02:00
osd.c player: modify/simplify AB-loop behavior 2019-09-19 20:37:05 +02:00
playloop.c player: ensure backward playback state is propagated on track switching 2019-09-19 20:37:05 +02:00
screenshot.c image_writer: move convert_image() to player/screenshot.c 2019-09-14 23:02:39 +02:00
screenshot.h image_writer: move convert_image() to player/screenshot.c 2019-09-14 23:02:39 +02:00
scripting.c scripting: change when/how player waits for scripts being loaded 2018-04-18 01:17:41 +03:00
sub.c player: ensure backward playback state is propagated on track switching 2019-09-19 20:37:05 +02:00
video.c player: ensure backward playback state is propagated on track switching 2019-09-19 20:37:05 +02:00