diff mplayer.c @ 19973:02a18c52a42a

after a long time, finally i could add -endpos option to mplayer executable. as oded told me on 1006 02 24, i applied it, blame me if some problem occurs, i hope not, since i tried it for a while....
author ptt
date Mon, 25 Sep 2006 16:47:56 +0000
parents ef94dfe93fe8
children 42b46a42f83b
line wrap: on
line diff
--- a/mplayer.c	Mon Sep 25 16:16:19 2006 +0000
+++ b/mplayer.c	Mon Sep 25 16:47:56 2006 +0000
@@ -250,6 +250,8 @@
 static int loop_times=-1;
 static int loop_seek=0;
 
+static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
+
 // A/V sync:
        int autosync=0; // 30 might be a good default value.
 
@@ -4050,10 +4052,16 @@
 
 if(!sh_video) {
   // handle audio-only case:
-  if(!quiet) {
-    double a_pos = playing_audio_pts(sh_audio, d_audio, audio_out);
+  double a_pos=0;
+  if(!quiet || end_at.type == END_AT_TIME )
+    a_pos = playing_audio_pts(sh_audio, d_audio, audio_out);
+
+  if(!quiet)
     print_status(a_pos, 0, 0);
-  }
+
+  if(end_at.type == END_AT_TIME && end_at.pos < a_pos)
+    eof = PT_NEXT_ENTRY;
+
 } else {
 
 /*========================== PLAY VIDEO ============================*/
@@ -4296,6 +4304,10 @@
 		too_slow_frame_cnt++;
 		/* printf ("PANIC: too slow frame (%.3f)!\n", j); */
 
+           // FIXME: add size based support for -endpos
+           if ( end_at.type == END_AT_TIME && end_at.pos < sh_video->pts )
+                eof = PT_NEXT_ENTRY;
+
 	   if(vo_config_count) video_out->flip_page();
 	   if (play_n_frames >= 0) {
 	     --play_n_frames;
@@ -5214,6 +5226,15 @@
      seek_to_sec = NULL;
   }
   
+  if (end_at.type != END_AT_NONE) {
+    if(end_at.type == END_AT_SIZE) {
+      mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_MPEndposNoSizeBased);
+      end_at.type = END_AT_NONE;
+    } else {
+      end_at.pos += rel_seek_secs;
+    }
+  }
+
   /* Looping. */
   if(eof==1 && loop_times>=0) {
     int l = loop_times;