[MPlayer-cvslog] r33363 - trunk/mplayer.c

reimar subversion at mplayerhq.hu
Wed May 4 22:13:26 CEST 2011


Author: reimar
Date: Wed May  4 22:13:25 2011
New Revision: 33363

Log:
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.

Modified:
   trunk/mplayer.c

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Wed May  4 17:16:35 2011	(r33362)
+++ trunk/mplayer.c	Wed May  4 22:13:25 2011	(r33363)
@@ -637,6 +637,29 @@ void uninit_player(unsigned int mask){
     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 @@ if(1 || mpctx->sh_video) {
   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 @@ if(benchmark){
 // 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) {


More information about the MPlayer-cvslog mailing list