1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-30 19:22:11 +00:00

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.
This commit is contained in:
wm4 2013-10-28 23:16:00 +01:00
parent 96a60e15ce
commit 40e68d6514
2 changed files with 24 additions and 10 deletions

View File

@ -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

View File

@ -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);