Mercurial > mplayer.hg
changeset 33276:e7f4c0ae303d
Move freeing of subtitle data to uninit_player so it not only happens
on switching files but also when exiting.
The makes it easier to debug memleaks with valgrind.
author | reimar |
---|---|
date | Wed, 04 May 2011 20:13:25 +0000 |
parents | 2cd61a522248 |
children | 16dcb1b753eb |
files | mplayer.c |
diffstat | 1 files changed, 25 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/mplayer.c Wed May 04 15:16:35 2011 +0000 +++ b/mplayer.c Wed May 04 20:13:25 2011 +0000 @@ -637,6 +637,29 @@ getch2_disable(); } + if (mask & INITIALIZED_SUBS) { + initialized_flags &= ~INITIALIZED_SUBS; + if (mpctx->set_of_sub_size > 0) { + int i; + current_module="sub_free"; + for (i = 0; i < mpctx->set_of_sub_size; ++i) { + sub_free(mpctx->set_of_subtitles[i]); +#ifdef CONFIG_ASS + if (mpctx->set_of_ass_tracks[i]) + ass_free_track(mpctx->set_of_ass_tracks[i]); +#endif + } + mpctx->set_of_sub_size = 0; + } + vo_sub_last = vo_sub= NULL; + subdata = NULL; +#ifdef CONFIG_ASS + ass_track = NULL; + if (ass_library) + ass_clear_fonts(ass_library); +#endif + } + if(mask&INITIALIZED_VOBSUB){ initialized_flags&=~INITIALIZED_VOBSUB; current_module="uninit_vobsub"; @@ -3513,6 +3536,8 @@ load_subtitles(filename, fps, add_subtitles); if (mpctx->set_of_sub_size > 0) mpctx->sub_counts[SUB_SOURCE_SUBS] = mpctx->set_of_sub_size; + // set even if we have no subs yet, they may be added later + initialized_flags |= INITIALIZED_SUBS; } if (select_subtitle(mpctx)) { @@ -3995,25 +4020,6 @@ // time to uninit all, except global stuff: uninit_player(INITIALIZED_ALL-(INITIALIZED_GUI+INITIALIZED_INPUT+(fixed_vo?INITIALIZED_VO:0))); -if(mpctx->set_of_sub_size > 0) { - current_module="sub_free"; - for(i = 0; i < mpctx->set_of_sub_size; ++i) { - sub_free(mpctx->set_of_subtitles[i]); -#ifdef CONFIG_ASS - if(mpctx->set_of_ass_tracks[i]) - ass_free_track( mpctx->set_of_ass_tracks[i] ); -#endif - } - mpctx->set_of_sub_size = 0; -} -vo_sub_last = vo_sub=NULL; -subdata=NULL; -#ifdef CONFIG_ASS -ass_track = NULL; -if(ass_library) - ass_clear_fonts(ass_library); -#endif - if(mpctx->eof == PT_NEXT_ENTRY || mpctx->eof == PT_PREV_ENTRY) { mpctx->eof = mpctx->eof == PT_NEXT_ENTRY ? 1 : -1; if(play_tree_iter_step(mpctx->playtree_iter,mpctx->play_tree_step,0) == PLAY_TREE_ITER_ENTRY) {