diff options
author | wm4 <wm4@nowhere> | 2015-02-18 21:10:43 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-02-18 21:12:57 +0100 |
commit | 102946ee0358924f22477435114785bd1f901ade (patch) | |
tree | 041231408c3ae32bee50902f700d68dd4fea55eb /player | |
parent | 37a0c9140ad85be8d184b626759f8d24ca69aa83 (diff) |
player: enable cache and demuxer thread for subtitles too
Includes some logic for not starting the demuxer thread for fully read
subtitles. (Well, the cache will still waste _lots_ of resources, and
the cache always has to be created, because we don't know whether it'll
be needed _before_ opening the file.)
See #1597.
Diffstat (limited to 'player')
-rw-r--r-- | player/loadfile.c | 8 | ||||
-rw-r--r-- | player/sub.c | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index aba8b6c7df..bbfff46fe2 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -291,8 +291,8 @@ static void enable_demux_thread(struct MPContext *mpctx) demux_start_thread(mpctx->demuxer); for (int n = 0; n < mpctx->num_tracks; n++) { struct track *track = mpctx->tracks[n]; - if (track->is_external && track->stream && - track->stream->type != STREAM_SUB) + if (track->is_external && track->stream && !track->preloaded && + !track->demuxer->fully_read) { demux_set_wakeup_cb(track->demuxer, wakeup_demux, mpctx); demux_start_thread(track->demuxer); @@ -689,6 +689,7 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename, struct stream *stream = stream_open(filename, mpctx->global); if (!stream) goto err_out; + stream_enable_cache(&stream, &opts->stream_cache); char *demuxer_name = NULL; switch (filter) { @@ -697,7 +698,6 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename, break; case STREAM_AUDIO: demuxer_name = opts->audio_demuxer_name; - stream_enable_cache(&stream, &opts->stream_cache); break; } @@ -731,6 +731,8 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename, } MP_TARRAY_APPEND(NULL, mpctx->sources, mpctx->num_sources, demuxer); + if (mpctx->playback_initialized) + enable_demux_thread(mpctx); return first; err_out: diff --git a/player/sub.c b/player/sub.c index 16affc4448..f4c9e7822b 100644 --- a/player/sub.c +++ b/player/sub.c @@ -321,6 +321,8 @@ static void reinit_subdec(struct MPContext *mpctx, struct track *track, if (!track->preloaded && track->is_external && !opts->sub_clear_on_seek) { demux_seek(track->demuxer, 0, SEEK_ABSOLUTE); track->preloaded = sub_read_all_packets(dec_sub, track->stream); + if (track->preloaded) + demux_stop_thread(track->demuxer); } } |