[MPlayer-cvslog] r35107 - in trunk: libmpdemux/demux_lavf.c stream/cache2.c

reimar subversion at mplayerhq.hu
Sat Aug 18 21:51:58 CEST 2012


Author: reimar
Date: Sat Aug 18 21:51:58 2012
New Revision: 35107

Log:
Update endpos each time libavformat asks for it.

Fixes playback of still downloading files to not stop before we
really reached the end.

Modified:
   trunk/libmpdemux/demux_lavf.c
   trunk/stream/cache2.c

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	Sat Aug 18 21:38:47 2012	(r35106)
+++ trunk/libmpdemux/demux_lavf.c	Sat Aug 18 21:51:58 2012	(r35107)
@@ -105,9 +105,13 @@ static int64_t mp_seek(void *opaque, int
         pos += stream->end_pos;
     else if(whence == SEEK_SET)
         pos += stream->start_pos;
-    else if(whence == AVSEEK_SIZE && stream->end_pos > 0)
+    else if(whence == AVSEEK_SIZE && stream->end_pos > 0) {
+        off_t size;
+        stream_control(stream, STREAM_CTRL_GET_SIZE, &size);
+        if (size > stream->end_pos)
+            stream->end_pos = size;
         return stream->end_pos - stream->start_pos;
-    else
+    } else
         return -1;
 
     if(pos<0)

Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c	Sat Aug 18 21:38:47 2012	(r35106)
+++ trunk/stream/cache2.c	Sat Aug 18 21:51:58 2012	(r35107)
@@ -91,7 +91,7 @@ typedef struct {
   // callback
   stream_t* stream;
   volatile int control;
-  volatile unsigned control_uint_arg;
+  volatile uint64_t control_uint_arg;
   volatile double control_double_arg;
   volatile struct stream_lang_req control_lang_arg;
   volatile int control_res;
@@ -264,6 +264,7 @@ static int cache_fill(cache_vars_t *s)
 static int cache_execute_control(cache_vars_t *s) {
   double double_res;
   unsigned uint_res;
+  unsigned uint64_res;
   int needs_flush = 0;
   static unsigned last;
   int quit = s->control == -2;
@@ -316,6 +317,10 @@ static int cache_execute_control(cache_v
       s->control_res = s->stream->control(s->stream, s->control, &uint_res);
       s->control_uint_arg = uint_res;
       break;
+    case STREAM_CTRL_GET_SIZE:
+      s->control_res = s->stream->control(s->stream, s->control, &uint64_res);
+      s->control_uint_arg = uint64_res;
+      break;
     case STREAM_CTRL_GET_LANG:
       s->control_res = s->stream->control(s->stream, s->control, (void *)&s->control_lang_arg);
       break;
@@ -640,6 +645,7 @@ int cache_do_control(stream_t *stream, i
     case STREAM_CTRL_GET_ASPECT_RATIO:
     case STREAM_CTRL_GET_NUM_ANGLES:
     case STREAM_CTRL_GET_ANGLE:
+    case STREAM_CTRL_GET_SIZE:
     case -2:
       s->control = cmd;
       break;
@@ -680,6 +686,9 @@ int cache_do_control(stream_t *stream, i
     case STREAM_CTRL_GET_ANGLE:
       *(unsigned *)arg = s->control_uint_arg;
       break;
+    case STREAM_CTRL_GET_SIZE:
+      *(off_t *)arg = s->control_uint_arg;
+      break;
     case STREAM_CTRL_GET_LANG:
       *(struct stream_lang_req *)arg = s->control_lang_arg;
       break;


More information about the MPlayer-cvslog mailing list