changeset 35013:4d94558867d6

Update endpos each time libavformat asks for it. Fixes playback of still downloading files to not stop before we really reached the end.
author reimar
date Sat, 18 Aug 2012 19:51:58 +0000
parents 144d16d56b45
children df3b195a810d
files libmpdemux/demux_lavf.c stream/cache2.c
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Sat Aug 18 19:38:47 2012 +0000
+++ b/libmpdemux/demux_lavf.c	Sat Aug 18 19:51:58 2012 +0000
@@ -105,9 +105,13 @@
         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)
--- a/stream/cache2.c	Sat Aug 18 19:38:47 2012 +0000
+++ b/stream/cache2.c	Sat Aug 18 19:51:58 2012 +0000
@@ -91,7 +91,7 @@
   // 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_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 @@
       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 @@
     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 @@
     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;