[vlc-devel] [PATCH] HLS: hls_Download: don't put stream_Read in a loop

Frédéric Yhuel fyhuel at viotech.net
Thu Mar 29 14:34:03 CEST 2012


Maybe I missed something, but it seems to me that either that patch must
be applied, either "stream_Read" documentation must be fixed.
---
 modules/stream_filter/httplive.c |   32 +++++++-------------------------
 1 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index a8dfc4b..6a711be 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1713,32 +1713,14 @@ static int hls_Download(stream_t *s, segment_t *segment)
 
     assert(segment->data->i_buffer == segment->size);
 
-    ssize_t length = 0, curlen = 0;
-    uint64_t size;
-    do
+    int read = stream_Read(p_ts, segment->data->p_buffer, segment->size);
+    if (read < (int)segment->size)
     {
-        size = stream_Size(p_ts);
-        if (size > segment->size)
-        {
-            msg_Dbg(s, "size changed %"PRIu64, segment->size);
-            block_t *p_block = block_Realloc(segment->data, 0, size);
-            if (p_block == NULL)
-            {
-                stream_Delete(p_ts);
-                block_Release(segment->data);
-                segment->data = NULL;
-                return VLC_ENOMEM;
-            }
-            segment->data = p_block;
-            segment->size = size;
-            assert(segment->data->i_buffer == segment->size);
-            p_block = NULL;
-        }
-        length = stream_Read(p_ts, segment->data->p_buffer + curlen, segment->size - curlen);
-        if (length <= 0)
-            break;
-        curlen += length;
-    } while (vlc_object_alive(s));
+        msg_Err(s, "hls_Download: I requested %"PRIu64" bytes, "\
+                "but I got only %i", segment->size, read);
+        segment->size = read;
+        segment->data->i_buffer = read;
+    }
 
     stream_Delete(p_ts);
     return VLC_SUCCESS;
-- 
1.7.5.4




More information about the vlc-devel mailing list