mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
demux: disable stream cache if no tracks are selected
Slightly helps with timeline stuff, like EDL. There is no need to keep network (or even just disk I/O) busy for all segments at the same time, because 1. the data won't be needed any time soon, and 2. will probably be discarded anyway if the stream is seeked when segment is resumed. Partially fixes #2692.
This commit is contained in:
parent
5986861c9c
commit
46bcdb7039
@ -558,11 +558,18 @@ static void execute_trackswitch(struct demux_internal *in)
|
|||||||
{
|
{
|
||||||
in->tracks_switched = false;
|
in->tracks_switched = false;
|
||||||
|
|
||||||
|
bool any_selected = false;
|
||||||
|
for (int n = 0; n < in->num_streams; n++)
|
||||||
|
any_selected |= in->streams[n]->ds->selected;
|
||||||
|
|
||||||
pthread_mutex_unlock(&in->lock);
|
pthread_mutex_unlock(&in->lock);
|
||||||
|
|
||||||
if (in->d_thread->desc->control)
|
if (in->d_thread->desc->control)
|
||||||
in->d_thread->desc->control(in->d_thread, DEMUXER_CTRL_SWITCHED_TRACKS, 0);
|
in->d_thread->desc->control(in->d_thread, DEMUXER_CTRL_SWITCHED_TRACKS, 0);
|
||||||
|
|
||||||
|
stream_control(in->d_thread->stream, STREAM_CTRL_SET_READAHEAD,
|
||||||
|
&(int){any_selected});
|
||||||
|
|
||||||
pthread_mutex_lock(&in->lock);
|
pthread_mutex_lock(&in->lock);
|
||||||
|
|
||||||
if (in->start_refresh_seek)
|
if (in->start_refresh_seek)
|
||||||
@ -1077,6 +1084,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
|
|||||||
demux_init_cache(demuxer);
|
demux_init_cache(demuxer);
|
||||||
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
|
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
|
||||||
demux_update(demuxer);
|
demux_update(demuxer);
|
||||||
|
stream_control(demuxer->stream, STREAM_CTRL_SET_READAHEAD, &(int){false});
|
||||||
return demuxer;
|
return demuxer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,10 @@ bool timeline_switch_to_time(struct MPContext *mpctx, double pts)
|
|||||||
|
|
||||||
if (mpctx->demuxer) {
|
if (mpctx->demuxer) {
|
||||||
demux_stop_thread(mpctx->demuxer);
|
demux_stop_thread(mpctx->demuxer);
|
||||||
demux_flush(mpctx->demuxer);
|
for (int i = 0; i < demux_get_num_stream(mpctx->demuxer); i++) {
|
||||||
|
struct sh_stream *sh = demux_get_stream(mpctx->demuxer, i);
|
||||||
|
demuxer_select_track(mpctx->demuxer, sh, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpctx->demuxer = n->source;
|
mpctx->demuxer = n->source;
|
||||||
|
Loading…
Reference in New Issue
Block a user