hlsenc: keep the playlist to the correct number of items
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 25 Dec 2012 09:05:42 +0000 (10:05 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Sat, 29 Dec 2012 16:26:30 +0000 (17:26 +0100)
Consider the corner case with a list size larger than the wrap
number.

libavformat/hlsenc.c

index 7abb46d..39e8df9 100644 (file)
@@ -48,6 +48,7 @@ typedef struct HLSContext {
     int has_video;
     int64_t start_pts;
     int64_t end_pts;
+    int nb_entries;
     ListEntry *list;
     ListEntry *end_list;
     char *basename;
@@ -97,11 +98,12 @@ static int append_entry(HLSContext *hls, uint64_t duration)
 
     hls->end_list = en;
 
-    if (hls->number >= hls->size) {
+    if (hls->nb_entries >= hls->size) {
         en = hls->list;
         hls->list = en->next;
         av_free(en);
-    }
+    } else
+        hls->nb_entries++;
 
     return 0;
 }