diff options
author | wm4 <wm4@nowhere> | 2014-10-03 19:57:49 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-03 23:05:09 +0200 |
commit | 9d5d031b6d23402a465618892a40b7af6d4e3c28 (patch) | |
tree | 143f43c4b002ec74f7172038e58409723647d892 /player/sub.c | |
parent | 9570976255083c1ec32add62613c52ad98fa28c8 (diff) | |
download | mpv-9d5d031b6d23402a465618892a40b7af6d4e3c28.tar.bz2 mpv-9d5d031b6d23402a465618892a40b7af6d4e3c28.tar.xz |
player: remove central uninit_player() function and flags mess
Each subsystem (or similar thing) had an INITIALIZED_ flag assigned. The
main use of this was that you could pass a bitmask of these flags to
uninit_player(). Except in some situations where you wanted to
uninitialize nearly everything, this wasn't really useful. Moreover, it
was quite annoying that subsystems had most of the code in a specific
file, but the uninit code in loadfile.c (because that's where
uninit_player() was implemented).
Simplify all this. Remove the flags; e.g. instead of testing for the
INITIALIZED_AO flag, test whether mpctx->ao is set. Move uninit code
to separate functions, e.g. uninit_audio_out().
Diffstat (limited to 'player/sub.c')
-rw-r--r-- | player/sub.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/player/sub.c b/player/sub.c index 8f5f8ad8ac..6d2c5f06a5 100644 --- a/player/sub.c +++ b/player/sub.c @@ -38,7 +38,7 @@ #include "core.h" -void uninit_subs(struct demuxer *demuxer) +void uninit_stream_sub_decoders(struct demuxer *demuxer) { for (int i = 0; i < demuxer->num_streams; i++) { struct sh_stream *sh = demuxer->streams[i]; @@ -49,6 +49,23 @@ void uninit_subs(struct demuxer *demuxer) } } +void uninit_sub(struct MPContext *mpctx, int order) +{ + if (mpctx->d_sub[order]) { + mpctx->d_sub[order] = NULL; // Note: not free'd. + int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB; + osd_set_sub(mpctx->osd, obj, NULL); + reset_subtitles(mpctx, order); + reselect_demux_streams(mpctx); + } +} + +void uninit_sub_all(struct MPContext *mpctx) +{ + uninit_sub(mpctx, 0); + uninit_sub(mpctx, 1); +} + // When reading subtitles from a demuxer, and we read video or audio from the // demuxer, we should not explicitly read subtitle packets. (With external // subs, we have to.) @@ -85,17 +102,13 @@ void reset_subtitle_state(struct MPContext *mpctx) static void update_subtitle(struct MPContext *mpctx, int order) { struct MPOpts *opts = mpctx->opts; - if (order == 0) { - if (!(mpctx->initialized_flags & INITIALIZED_SUB)) - return; - } else { - if (!(mpctx->initialized_flags & INITIALIZED_SUB2)) - return; - } - struct track *track = mpctx->current_track[order][STREAM_SUB]; struct dec_sub *dec_sub = mpctx->d_sub[order]; - assert(track && dec_sub); + + if (!track) + return; + + assert(dec_sub); int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB; if (mpctx->d_video) { @@ -190,30 +203,20 @@ void reinit_subs(struct MPContext *mpctx, int order) struct MPOpts *opts = mpctx->opts; struct track *track = mpctx->current_track[order][STREAM_SUB]; int obj = order ? OSDTYPE_SUB2 : OSDTYPE_SUB; - int init_flag = order ? INITIALIZED_SUB2 : INITIALIZED_SUB; - assert(!(mpctx->initialized_flags & init_flag)); + assert(!mpctx->d_sub[order]); struct sh_stream *sh = track ? track->stream : NULL; if (!sh) return; - if (!sh->sub->dec_sub) { - assert(!mpctx->d_sub[order]); + // The decoder is cached in the stream header in order to make ordered + // chapters work better. + if (!sh->sub->dec_sub) sh->sub->dec_sub = sub_create(mpctx->global); - } - - assert(!mpctx->d_sub[order] || sh->sub->dec_sub == mpctx->d_sub[order]); - - // The decoder is kept in the stream header in order to make ordered - // chapters work well. mpctx->d_sub[order] = sh->sub->dec_sub; - mpctx->initialized_flags |= init_flag; - struct dec_sub *dec_sub = mpctx->d_sub[order]; - assert(dec_sub); - reinit_subdec(mpctx, track, dec_sub); struct osd_sub_state state = { |