diff options
author | wm4 <wm4@nowhere> | 2013-10-28 23:16:00 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-10-28 23:16:00 +0100 |
commit | 40e68d65146518b9db2380a571b7dd6dabcf3585 (patch) | |
tree | a41be1534c7dd7074413ea6ddf5f7940d31231ac /mpvcore | |
parent | 96a60e15ce7b813d71f8988a0a938fe98e90d7ca (diff) | |
download | mpv-40e68d65146518b9db2380a571b7dd6dabcf3585.tar.bz2 mpv-40e68d65146518b9db2380a571b7dd6dabcf3585.tar.xz |
mplayer: handle subtitle renderer cleanup via uninit_player
This might actually fix an issue with DVB channel switching, because
that uses some sort of hack to reinitialize the demuxer, which causes
the subtitle renderer to initialize twice. As consequence, the assert in
add_subtitle_fonts_from_sources() would trigger.
I didn't actually test the DVB case, because I don't have the hardware.
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/mp_core.h | 1 | ||||
-rw-r--r-- | mpvcore/mplayer.c | 33 |
2 files changed, 24 insertions, 10 deletions
diff --git a/mpvcore/mp_core.h b/mpvcore/mp_core.h index 28f34ee580..6d83be182a 100644 --- a/mpvcore/mp_core.h +++ b/mpvcore/mp_core.h @@ -30,6 +30,7 @@ #define INITIALIZED_AO 2 #define INITIALIZED_GETCH2 8 #define INITIALIZED_PLAYBACK 16 +#define INITIALIZED_LIBASS 32 #define INITIALIZED_STREAM 64 #define INITIALIZED_DEMUXER 512 #define INITIALIZED_ACODEC 1024 diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c index 917f445556..480149a17e 100644 --- a/mpvcore/mplayer.c +++ b/mpvcore/mplayer.c @@ -468,6 +468,16 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) reset_subtitles(mpctx); } + if (mask & INITIALIZED_LIBASS) { + mpctx->initialized_flags &= ~INITIALIZED_LIBASS; +#ifdef CONFIG_ASS + if (mpctx->osd->ass_renderer) + ass_renderer_done(mpctx->osd->ass_renderer); + mpctx->osd->ass_renderer = NULL; + ass_clear_fonts(mpctx->ass_library); +#endif + } + if (mask & INITIALIZED_VCODEC) { mpctx->initialized_flags &= ~INITIALIZED_VCODEC; if (mpctx->sh_video) @@ -4229,14 +4239,21 @@ static void add_subtitle_fonts_from_sources(struct MPContext *mpctx) } } } +#endif +} - // libass seems to misbehave if fonts are changed while a renderer - // exists, so we (re)create the renderer after fonts are set. +static void init_sub_renderer(struct MPContext *mpctx) +{ +#ifdef CONFIG_ASS + assert(!(mpctx->initialized_flags & INITIALIZED_LIBASS)); assert(!mpctx->osd->ass_renderer); + mpctx->osd->ass_renderer = ass_renderer_init(mpctx->osd->ass_library); - if (mpctx->osd->ass_renderer) + if (mpctx->osd->ass_renderer) { mp_ass_configure_fonts(mpctx->osd->ass_renderer, mpctx->opts->sub_text_style); + } + mpctx->initialized_flags |= INITIALIZED_LIBASS; #endif } @@ -4538,6 +4555,9 @@ goto_reopen_demuxer: ; timeline_set_part(mpctx, mpctx->timeline_part, true); add_subtitle_fonts_from_sources(mpctx); + // libass seems to misbehave if fonts are changed while a renderer + // exists, so we (re)create the renderer after fonts are set. + init_sub_renderer(mpctx); open_subtitles_from_options(mpctx); open_subtitles_from_resolve(mpctx); @@ -4696,13 +4716,6 @@ terminate_playback: // don't jump here after ao/vo/getch initialization! talloc_free(mpctx->resolve_result); mpctx->resolve_result = NULL; -#ifdef CONFIG_ASS - if (mpctx->osd->ass_renderer) - ass_renderer_done(mpctx->osd->ass_renderer); - mpctx->osd->ass_renderer = NULL; - ass_clear_fonts(mpctx->ass_library); -#endif - // Played/paused for longer than 3 seconds -> ok bool playback_short = mpctx->stop_play == AT_END_OF_FILE && (playback_start < 0 || mp_time_sec() - playback_start < 3.0); |