summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-09-07 23:02:36 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:04 +0200
commit5114c69c7f85e7cd38d6928e874c5b44c951be60 (patch)
tree7aacce1ca7905545cba48c2604071d62bd434135 /demux/demux_lavf.c
parentb1c202c12fdd2b53f49e7a9ca5c2f4b84733f511 (diff)
downloadmpv-5114c69c7f85e7cd38d6928e874c5b44c951be60.tar.bz2
mpv-5114c69c7f85e7cd38d6928e874c5b44c951be60.tar.xz
demux: change hack for closing subtitle files early
Subtitles (and a few other file types, like playlists) are not streamed, but fully read on opening. This means keeping the file handle or network socket open is a waste of resources and could cause other weird behavior. This is why there's a hack to close them after opening. Change this hack to make the demuxer itself do this, which is less weird. (Until recently, demuxer->stream ownership was more complex, which is why it was done this way.) There is some evil shit due to a huge ownership/lifetime mess of various objects. Especially EDL (the currently only nested demuxer case) requires being careful about mp_cancel and passing down stream pointers. As one defensive programming measure, stop accessing the "stream" variable in open_given_type(), even where it would still work. This includes removing a redundant line of code, and removing the peak call, which should not be needed anymore, as the remaining demuxers do this mostly correctly.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 19997a1855..eae78f9b4c 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -1063,6 +1063,14 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
demuxer->seekable = true;
}
+ if (demuxer->fully_read) {
+ demux_close_stream(demuxer);
+ if (priv->own_stream)
+ free_stream(priv->stream);
+ priv->own_stream = false;
+ priv->stream = demuxer->stream;
+ }
+
return 0;
}
@@ -1179,18 +1187,10 @@ static void demux_seek_lavf(demuxer_t *demuxer, double seek_pts, int flags)
static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
{
- lavf_priv_t *priv = demuxer->priv;
-
switch (cmd) {
case DEMUXER_CTRL_SWITCHED_TRACKS:
select_tracks(demuxer, 0);
return CONTROL_OK;
- case DEMUXER_CTRL_REPLACE_STREAM:
- if (priv->own_stream)
- free_stream(priv->stream);
- priv->own_stream = false;
- priv->stream = demuxer->stream;
- return CONTROL_OK;
default:
return CONTROL_UNKNOWN;
}