]> git.sesse.net Git - ffmpeg/commitdiff
lavf/hls: replace the same code logic with ensure_playlist()
authorvacingfang <vacingfang@tencent.com>
Sun, 21 Jul 2019 13:55:47 +0000 (21:55 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Fri, 26 Jul 2019 01:39:47 +0000 (09:39 +0800)
Replace the same code logic with ensure_playlist(), it's will
help reusable blocks of code.

Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: vacingfang <vacingfang@tencent.com>
libavformat/hls.c

index 238ebd0729a4ac44d89d4569d8d7890b821ad43c..052244592ccea8a36a4ec0dfefb235c2e25ac1b8 100644 (file)
@@ -861,13 +861,9 @@ static int parse_playlist(HLSContext *c, const char *url,
             }
             if (is_segment) {
                 struct segment *seg;
-                if (!pls) {
-                    if (!new_variant(c, 0, url, NULL)) {
-                        ret = AVERROR(ENOMEM);
-                        goto fail;
-                    }
-                    pls = c->playlists[c->n_playlists - 1];
-                }
+                ret = ensure_playlist(c, &pls, url);
+                if (ret < 0)
+                    goto fail;
                 seg = av_malloc(sizeof(struct segment));
                 if (!seg) {
                     ret = AVERROR(ENOMEM);