[vlc-commits] Fix trying to prefetch 2 segments from a 1-segment HLS stream

Chris Smowton git at videolan.org
Thu May 31 01:26:13 CEST 2012


vlc | branch: master | Chris Smowton <cs448 at cam.ac.uk> | Wed May 30 14:30:04 2012 +0100| [7e21f34f1cf7fd9f3c9d73b5b39d7c671101d22c] | committer: Jean-Baptiste Kempf

Fix trying to prefetch 2 segments from a 1-segment HLS stream

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7e21f34f1cf7fd9f3c9d73b5b39d7c671101d22c
---

 modules/stream_filter/httplive.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 413247a..8690b0a 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1652,8 +1652,13 @@ static int Prefetch(stream_t *s, int *current)
     if (hls == NULL)
         return VLC_EGENERIC;
 
-    /* Download first 2 segments of this HLS stream */
-    for (int i = 0; i < 2; i++)
+    if (vlc_array_count(hls->segments) == 0)
+        return VLC_EGENERIC;
+    else if (vlc_array_count(hls->segments) == 1 && p_sys->b_live)
+        msg_Warn(s, "Only 1 segment available to prefetch in live stream; may stall");
+
+    /* Download first 2 segments of this HLS stream if they exist */
+    for (int i = 0; i < __MIN(vlc_array_count(hls->segments), 2); i++)
     {
         segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
         if (segment == NULL )



More information about the vlc-commits mailing list