diff mbox

[FFmpeg-devel] avformat/avio: fix off-by-one in retry_transfer_wrapper

Message ID 20180109081539.834-1-lachs0r@srsfckn.biz
State New
Headers show

Commit Message

Martin Herkt Jan. 9, 2018, 8:15 a.m. UTC
This reportedly fixes hangs with segmented streams.
Affects playback via Schannel on Windows in particular.

Can be reproduced with any YouTube live stream.
---
 libavformat/avio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

wm4 Jan. 9, 2018, 7:31 p.m. UTC | #1
On Tue,  9 Jan 2018 09:15:39 +0100
Martin Herkt <lachs0r@srsfckn.biz> wrote:

> This reportedly fixes hangs with segmented streams.
> Affects playback via Schannel on Windows in particular.
> 
> Can be reproduced with any YouTube live stream.
> ---
>  libavformat/avio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 63e82872f7..cd1e325a6b 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -393,7 +393,7 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
>              }
>          } else if (ret == AVERROR_EOF)
>              return (len > 0) ? len : AVERROR_EOF;
> -        else if (ret < 0)
> +        else if (ret <= 0)
>              return ret;
>          if (ret) {
>              fast_retries = FFMAX(fast_retries, 2);

This was explicitly changed with the EOF change (that broke a lot of
stuff), so this is probably not correct. The intention is very much to
retry if the result is 0.
diff mbox

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 63e82872f7..cd1e325a6b 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -393,7 +393,7 @@  static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
             }
         } else if (ret == AVERROR_EOF)
             return (len > 0) ? len : AVERROR_EOF;
-        else if (ret < 0)
+        else if (ret <= 0)
             return ret;
         if (ret) {
             fast_retries = FFMAX(fast_retries, 2);