[MPlayer-cvslog] r37310 - in trunk: libmpdemux/demux_lavf.c stream/stream.c stream/stream.h

reimar subversion at mplayerhq.hu
Sat Oct 25 17:27:09 CEST 2014


Author: reimar
Date: Sat Oct 25 17:27:09 2014
New Revision: 37310

Log:
stream: Fix unreliable probe behaviour on non-seekable streams.

We assumed that we could probe STREAM_BUFFER_SIZE bytes and
then seek to the back.
However this was not the case if the protocol could return with
a short read.
Instead ensure that a buffer fill always guarantees a seekback of
STREAM_BUFFER_MIN.

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

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	Sat Oct 25 17:27:08 2014	(r37309)
+++ trunk/libmpdemux/demux_lavf.c	Sat Oct 25 17:27:09 2014	(r37310)
@@ -45,7 +45,7 @@
 
 #include "mp_taglists.h"
 
-#define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE
+#define INITIAL_PROBE_SIZE STREAM_BUFFER_MIN
 #define SMALL_MAX_PROBE_SIZE (32 * 1024)
 #define PROBE_BUF_SIZE (2*1024*1024)
 

Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c	Sat Oct 25 17:27:08 2014	(r37309)
+++ trunk/stream/stream.c	Sat Oct 25 17:27:09 2014	(r37310)
@@ -359,10 +359,17 @@ int stream_fill_buffer(stream_t *s){
     return 0;
   s->buf_pos=0;
   s->buf_len=len;
+  while (s->buf_len < STREAM_BUFFER_MIN) {
+    assert(s->buf_len + STREAM_BUFFER_MIN < STREAM_BUFFER_SIZE);
+    len = stream_read_internal(s, s->buffer + s->buf_len, STREAM_BUFFER_MIN);
+    if (len <= 0)
+      break;
+    s->buf_len += len;
+  }
 //  printf("[%d]",len);fflush(stdout);
   if (s->capture_file)
     stream_capture_do(s);
-  return len;
+  return s->buf_len;
 }
 
 int stream_write_buffer(stream_t *s, unsigned char *buf, int len) {

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Sat Oct 25 17:27:08 2014	(r37309)
+++ trunk/stream/stream.h	Sat Oct 25 17:27:09 2014	(r37310)
@@ -51,7 +51,8 @@
 #define STREAMTYPE_BLURAY 20
 #define STREAMTYPE_BD 21
 
-#define STREAM_BUFFER_SIZE 2048
+#define STREAM_BUFFER_MIN 2048
+#define STREAM_BUFFER_SIZE (2*STREAM_BUFFER_MIN) // must be at least 2*STREAM_BUFFER_MIN
 #define STREAM_MAX_SECTOR_SIZE (8*1024)
 
 #define VCD_SECTOR_SIZE 2352


More information about the MPlayer-cvslog mailing list