summaryrefslogtreecommitdiffstats
path: root/demux/demux.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-08-26 13:05:14 +0200
committerwm4 <wm4@nowhere>2016-08-26 13:34:52 +0200
commitbc97d60542b353141bedeee985f9e5bd68b9f076 (patch)
tree63a0f4d0e077929ad0f46934e4f07c6016433e1f /demux/demux.h
parent4121016689668921538317449c0ea9063fc086fc (diff)
downloadmpv-bc97d60542b353141bedeee985f9e5bd68b9f076.tar.bz2
mpv-bc97d60542b353141bedeee985f9e5bd68b9f076.tar.xz
demux: close underlying stream if it's fully read anyway
This is for text subtitles. libavformat currently always reads text subtitles completely on init. This means the underlying stream is useless and will consume resources for various reasons (network connection, file handles, cache memory). Take care of this by closing the underlying stream if we think the demuxer has read everything. Since libavformat doesn't export whether it did (or whether it may access the stream again in the future), we rely on a whitelist. Also, instead of setting the stream to NULL or so, set it to an empty dummy stream. This way we don't have to litter the code with NULL checks. demux_lavf.c needs extra changes, because it tries to do clever things for the sake of subtitle charset conversion. The main reason we keep the demuxer etc. open is because we fell for libavformat being so generic, and we tried to remove corresponding special-cases in the higher-level player code. Some of this is forced due to ass/srt mkv/mp4 demuxing being very similar to external text files. In the future it might be better to do this in a more straight-forward way, such as reading text subtitles into libass and then discarding the demuxer entirely, but for aforementioned reasons this could be more of a mess than the solution introduced by this commit. Probably fixes #3456.
Diffstat (limited to 'demux/demux.h')
-rw-r--r--demux/demux.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/demux/demux.h b/demux/demux.h
index c7d1b8ee1d..9978335cfd 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -43,6 +43,7 @@ enum demux_ctrl {
DEMUXER_CTRL_STREAM_CTRL,
DEMUXER_CTRL_GET_READER_STATE,
DEMUXER_CTRL_GET_BITRATE_STATS, // double[STREAM_TYPE_COUNT]
+ DEMUXER_CTRL_REPLACE_STREAM,
};
struct demux_ctrl_reader_state {
@@ -220,6 +221,7 @@ typedef struct demuxer {
// thread-safe, only the demuxer is allowed to access the stream directly.
// You can freely use demux_stream_control() to send STREAM_CTRLs, or use
// demux_pause() to get exclusive access to the stream.
+ // Also note that the stream can get replaced if fully_read is set.
struct stream *stream;
} demuxer_t;