[FFmpeg-devel] [PATCH] avformat/aviobuf: let avio_read can retry when timeout

Wang Chuan ouchuanm at outlook.com
Fri Jan 14 04:42:37 EET 2022


If we meet timeout when reading network resource, avio_read will set
[eof_reached] to 1. And this prevent caller to retry since avio_read
do nothing and just return if eof_reached == 1.

Signed-off-by: Wang Chuan <ouchuanm at outlook.com>
---
  libavformat/aviobuf.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 29d4bd7510..38cb21debf 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -580,8 +580,9 @@ static void fill_buffer(AVIOContext *s)
             be done without rereading data */
          s->eof_reached = 1;
      } else if (len < 0) {
-        s->eof_reached = 1;
-        s->error= len;
+        s->error = len;
+        if (s->error != AVERROR(ETIMEDOUT))
+            s->eof_reached = 1;
      } else {
          s->pos += len;
          s->buf_ptr = dst;
-- 
2.29.2



More information about the ffmpeg-devel mailing list