]> git.sesse.net Git - vlc/commitdiff
Fix trying to prefetch 2 segments from a 1-segment HLS stream
authorChris Smowton <cs448@cam.ac.uk>
Wed, 30 May 2012 13:30:04 +0000 (14:30 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 30 May 2012 23:26:02 +0000 (01:26 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/stream_filter/httplive.c

index 413247a5c225928687918d8451fbffe9b2856e6a..8690b0afe2a2504a8c7e33f2e140da93d74d864c 100644 (file)
@@ -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 )