diff options
author | wm4 <wm4@nowhere> | 2015-12-26 18:32:27 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-12-26 18:32:27 +0100 |
commit | ce8524cb479f3b3339c6d2b3e0f5a45051145204 (patch) | |
tree | f82095783f5762c3229f6d7b71a029b794bf1efa /player/loadfile.c | |
parent | 504286b00689ad2c436bdd230b5a63cd66ba8cd6 (diff) | |
download | mpv-ce8524cb479f3b3339c6d2b3e0f5a45051145204.tar.bz2 mpv-ce8524cb479f3b3339c6d2b3e0f5a45051145204.tar.xz |
sub: cache subtitle state per track instead of per demuxer stream
Since commit 6d9cb893, subtitle state doesn't survive timeline switches
(ordered chapters etc.). So there is no point in caching the state per
sh_stream anymore (which would be required to deal with multiple
segments). Move the cache to struct track.
(Whether it's worth caching the subtitle state just for the situation
when subtitle tracks get reselected is questionable. But for now, it's
nice to have the subtitles immediately show up when reselecting a
subtitle.)
Diffstat (limited to 'player/loadfile.c')
-rw-r--r-- | player/loadfile.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index 8b35209d9f..f1664b2d9d 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -72,17 +72,15 @@ static void uninit_demuxer(struct MPContext *mpctx) mpctx->chapters = NULL; mpctx->num_chapters = 0; - // per-stream cached subtitle state - for (int i = 0; i < mpctx->num_sources; i++) - uninit_stream_sub_decoders(mpctx->sources[i]); - // close demuxers for external tracks for (int n = mpctx->num_tracks - 1; n >= 0; n--) { mpctx->tracks[n]->selected = false; mp_remove_track(mpctx, mpctx->tracks[n]); } - for (int i = 0; i < mpctx->num_tracks; i++) + for (int i = 0; i < mpctx->num_tracks; i++) { + sub_destroy(mpctx->tracks[i]->dec_sub); talloc_free(mpctx->tracks[i]); + } mpctx->num_tracks = 0; mpctx->timeline = NULL; @@ -337,10 +335,15 @@ bool timeline_switch_to_time(struct MPContext *mpctx, double pts) track->user_tid - 1); } - if (track->type == STREAM_SUB && track->stream) { - struct dec_sub *dec = track->stream->sub->dec_sub; - if (dec) - sub_control(dec, SD_CTRL_CLEAR, NULL); + if (track->dec_sub) { + for (int order = 0; order < 2; order++) { + if (mpctx->d_sub[order] == track->dec_sub) { + mpctx->d_sub[order] = NULL; + osd_set_sub(mpctx->osd, OSDTYPE_SUB + order, NULL); + } + } + sub_destroy(track->dec_sub); + track->dec_sub = NULL; } } } @@ -654,6 +657,8 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track) struct demuxer *d = track->demuxer; + sub_destroy(track->dec_sub); + int index = 0; while (index < mpctx->num_tracks && mpctx->tracks[index] != track) index++; @@ -674,7 +679,6 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track) break; } } - uninit_stream_sub_decoders(d); free_demuxer_and_stream(d); } |