changeset 22184:d9115ad11744

Clear/update subtitles after seeking backwards.
author reimar
date Sun, 11 Feb 2007 13:23:13 +0000
parents 36165d7a44b3
children 80ff3962cef4
files mplayer.c
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Sun Feb 11 11:03:09 2007 +0000
+++ b/mplayer.c	Sun Feb 11 13:23:13 2007 +0000
@@ -418,6 +418,7 @@
 int use_filedir_conf;
 
 static unsigned int inited_flags=0;
+static void update_subtitles(int reset);
 #define INITED_VO 1
 #define INITED_AO 2
 #define INITED_GUI 4
@@ -2364,14 +2365,12 @@
 #ifdef USE_DVDREAD
             if (vo_spudec && stream->type == STREAMTYPE_DVD) {
                 d_dvdsub->id = dvdsub_id;
-                spudec_reset(vo_spudec);
             }
 #endif
 
 #ifdef USE_DVDNAV
             if (vo_spudec && stream->type == STREAMTYPE_DVDNAV) {
                 d_dvdsub->id = dvdsub_id;
-                spudec_reset(vo_spudec);
             }
 #endif
             if (stream->type != STREAMTYPE_DVD && stream->type != STREAMTYPE_DVDNAV) {
@@ -2397,17 +2396,14 @@
 #endif
             }
         }
-    } else { // off
-        vo_osd_changed(OSDTYPE_SUBTITLE);
-        if(vo_spudec) vo_osd_changed(OSDTYPE_SPU);
     }
 #ifdef USE_DVDREAD
     if (vo_spudec && (stream->type == STREAMTYPE_DVD || stream->type == STREAMTYPE_DVDNAV) && dvdsub_id < 0 && reset_spu) {
         dvdsub_id = -2;
         d_dvdsub->id = dvdsub_id;
-        spudec_reset(vo_spudec);
     }
 #endif
+    update_subtitles(1);
 
     return M_PROPERTY_OK;
 }
@@ -2894,16 +2890,28 @@
 	audio_out->get_delay();
 }
 
-static void update_subtitles(void)
+static void update_subtitles(int reset)
 {
     unsigned char *packet=NULL;
     int len;
     char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
+    static subtitle subs;
     if (type == 'a')
 #ifdef USE_ASS
       if (!ass_enabled)
 #endif
       type = 't';
+    if (reset) {
+	sub_clear_text(&subs, MP_NOPTS_VALUE);
+	if (vo_sub) {
+	    vo_sub = NULL;
+	    vo_osd_changed(OSDTYPE_SUBTITLE);
+	}
+	if (vo_spudec) {
+	    spudec_reset(vo_spudec);
+	    vo_osd_changed(OSDTYPE_SPU);
+	}
+    }
     // find sub
     if (subdata) {
 	double pts = sh_video->pts;
@@ -2964,7 +2972,6 @@
 	if (spudec_changed(vo_spudec))
 	    vo_osd_changed(OSDTYPE_SPU);
     } else if (dvdsub_id >= 0 && type == 't') {
-	static subtitle subs;
 	double curpts = sh_video->pts + sub_delay;
 	double endpts;
 	vo_sub = &subs;
@@ -3032,7 +3039,7 @@
 	current_module = "decode video";
 	decoded_frame = decode_video(sh_video, start, in_size, 0, pts);
 	if (decoded_frame) {
-	    update_subtitles();
+	    update_subtitles(0);
 	    update_osd_msg();
 	    current_module = "filter video";
 	    if (filter_video(sh_video, decoded_frame, sh_video->pts))
@@ -3462,7 +3469,7 @@
 		drop_frame = dropped_frames = 0;
 	    ++total_frame_cnt;
 	}
-	update_subtitles();
+	update_subtitles(0);
 	update_osd_msg();
 	current_module = "decode_video";
 	decoded_frame = decode_video(sh_video, start, in_size, drop_frame,
@@ -5629,7 +5636,7 @@
 	audio_time_usage=0; video_time_usage=0; vout_time_usage=0;
 	drop_frame_cnt=0;
 
-        if(vo_spudec) spudec_reset(vo_spudec);
+        update_subtitles(1);
       }
   }
 /*