diff options
author | wm4 <wm4@nowhere> | 2013-11-23 21:37:15 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-23 21:37:15 +0100 |
commit | 639e672bd153e06cfc01ced6c2a48b45870e8f31 (patch) | |
tree | 7b683231216221252860c9b686f744ad7354fa2f /mpvcore/player/loadfile.c | |
parent | 3486302514db31b8086f46226d9b46d53810d1e7 (diff) | |
download | mpv-639e672bd153e06cfc01ced6c2a48b45870e8f31.tar.bz2 mpv-639e672bd153e06cfc01ced6c2a48b45870e8f31.tar.xz |
player: rearrange how subtitle context and stream headers are used
Use sh_stream over sh_sub. Use dec_sub (and mpctx->d_sub) instead of the
stream header. This aligns the subtitle code with the recent audio and
video refactoring.
sh_sub still has the decoder context, though. This is because we want to
avoid reinit when switching segments with ordered chapters. (Reinit is
fast, except for creating the ASS_Renderer, which in turn triggers
fontconfig.) Not sure how much this matters, though, because the initial
segment switch will lazily initialize the decoder anyway.
Diffstat (limited to 'mpvcore/player/loadfile.c')
-rw-r--r-- | mpvcore/player/loadfile.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c index 51d3f2ec7e..33ee770b08 100644 --- a/mpvcore/player/loadfile.c +++ b/mpvcore/player/loadfile.c @@ -80,9 +80,10 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) if (mask & INITIALIZED_SUB) { mpctx->initialized_flags &= ~INITIALIZED_SUB; - if (mpctx->sh_sub) - sub_reset(mpctx->sh_sub->dec_sub); + if (mpctx->d_sub) + sub_reset(mpctx->d_sub); cleanup_demux_stream(mpctx, STREAM_SUB); + mpctx->d_sub = NULL; // Note: not free'd. mpctx->osd->dec_sub = NULL; reset_subtitles(mpctx); } @@ -108,13 +109,15 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) if (mask & INITIALIZED_DEMUXER) { mpctx->initialized_flags &= ~INITIALIZED_DEMUXER; + assert(!(mpctx->initialized_flags & + (INITIALIZED_VCODEC | INITIALIZED_ACODEC | INITIALIZED_SUB))); for (int i = 0; i < mpctx->num_tracks; i++) { talloc_free(mpctx->tracks[i]); } mpctx->num_tracks = 0; for (int t = 0; t < STREAM_TYPE_COUNT; t++) mpctx->current_track[t] = NULL; - assert(!mpctx->d_video && !mpctx->d_audio && !mpctx->sh_sub); + assert(!mpctx->d_video && !mpctx->d_audio && !mpctx->d_sub); mpctx->master_demuxer = NULL; for (int i = 0; i < mpctx->num_sources; i++) { uninit_subs(mpctx->sources[i]); @@ -264,22 +267,12 @@ static void print_file_properties(struct MPContext *mpctx) } } -static void set_demux_field(struct MPContext *mpctx, enum stream_type type, - struct sh_stream *s) -{ - mpctx->sh[type] = s; - // redundant fields for convenience access - switch(type) { - case STREAM_SUB: mpctx->sh_sub = s ? s->sub : NULL; break; - } -} - struct sh_stream *init_demux_stream(struct MPContext *mpctx, enum stream_type type) { struct track *track = mpctx->current_track[type]; - set_demux_field(mpctx, type, track ? track->stream : NULL); - struct sh_stream *stream = mpctx->sh[type]; + struct sh_stream *stream = track ? track->stream : NULL; + mpctx->sh[type] = stream; if (stream) { demuxer_switch_track(stream->demuxer, type, stream); if (track->is_external) { @@ -295,7 +288,7 @@ void cleanup_demux_stream(struct MPContext *mpctx, enum stream_type type) struct sh_stream *stream = mpctx->sh[type]; if (stream) demuxer_switch_track(stream->demuxer, type, NULL); - set_demux_field(mpctx, type, NULL); + mpctx->sh[type] = NULL; } // Switch the demuxers to current track selection. This is possibly important @@ -1051,7 +1044,7 @@ static void play_current_file(struct MPContext *mpctx) assert(mpctx->demuxer == NULL); assert(mpctx->d_audio == NULL); assert(mpctx->d_video == NULL); - assert(mpctx->sh_sub == NULL); + assert(mpctx->d_sub == NULL); char *stream_filename = mpctx->filename; mpctx->resolve_result = resolve_url(stream_filename, opts); |