[05/10] hls: Check that the streams have been initialized before checking their discard flags

Message ID 1375038091-92151-5-git-send-email-martin@martin.st
State Committed
Commit cdd2d73d315ecaf19ff49e64c91923275f1bda68
Headers show

Commit Message

Martin Storsjö July 28, 2013, 7:01 p.m.
From: Michael Niedermayer <michaelni@gmx.at>

If passing the end of one segment while initializing the
chained demuxer, the outer demuxer's streams aren't set up
yet, so we can't recheck the discard flags.
---
 libavformat/hls.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Luca Barbato July 28, 2013, 8:08 p.m. | #1
On 28/07/13 21:01, Martin Storsjö wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
> 
> If passing the end of one segment while initializing the
> chained demuxer, the outer demuxer's streams aren't set up
> yet, so we can't recheck the discard flags.
> ---
>  libavformat/hls.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index ef5bb78..5cb00b7 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -427,7 +427,8 @@ reload:
>      c->end_of_segment = 1;
>      c->cur_seq_no = v->cur_seq_no;
>  
> -    if (v->ctx && v->ctx->nb_streams) {
> +    if (v->ctx && v->ctx->nb_streams &&
> +        v->parent->nb_streams >= v->stream_offset + v->ctx->nb_streams) {
>          v->needed = 0;
>          for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams;
>               i++) {
> 

Ok, after you explained me on chat. Could you please change the
subject/commit message to be in line with what you told me?

lu

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ef5bb78..5cb00b7 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -427,7 +427,8 @@  reload:
     c->end_of_segment = 1;
     c->cur_seq_no = v->cur_seq_no;
 
-    if (v->ctx && v->ctx->nb_streams) {
+    if (v->ctx && v->ctx->nb_streams &&
+        v->parent->nb_streams >= v->stream_offset + v->ctx->nb_streams) {
         v->needed = 0;
         for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams;
              i++) {