diff mbox

[FFmpeg-devel,V1,3/3] lavf/hls: replace the same code logic with ensure_playlist()

Message ID 1563719497-3780-3-git-send-email-mypopydev@gmail.com
State Accepted
Commit d83a3117e2f0b17a7742ec16d8fb39cddc272375
Headers show

Commit Message

Jun Zhao July 21, 2019, 2:31 p.m. UTC
From: vacingfang <vacingfang@tencent.com>

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 |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

Comments

Steven Liu July 25, 2019, 5:58 a.m. UTC | #1
Jun Zhao <mypopydev@gmail.com> 于2019年7月21日周日 下午10:32写道:
>
> From: vacingfang <vacingfang@tencent.com>
>
> 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 |   10 +++-------
>  1 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 238ebd0..0522445 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -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);
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".


LGTM

Thanks
mypopy@gmail.com July 26, 2019, 1:34 a.m. UTC | #2
On Thu, Jul 25, 2019 at 2:06 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Jun Zhao <mypopydev@gmail.com> 于2019年7月21日周日 下午10:32写道:
> >
> > From: vacingfang <vacingfang@tencent.com>
> >
> > 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 |   10 +++-------
> >  1 files changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > index 238ebd0..0522445 100644
> > --- a/libavformat/hls.c
> > +++ b/libavformat/hls.c
> > @@ -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);
> > --
> > 1.7.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
> LGTM
>
> Thanks
Will apply, Thanks
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 238ebd0..0522445 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -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);