[FFmpeg-devel] [PATCH] avio: Avoid endless loop in case no data arrives

Andrey Utkin andrey.krieger.utkin at gmail.com
Wed Mar 14 19:14:08 CET 2012


---8<---
This prevents situation when you launch ffmpeg or app to read UDP, and no data
arrives at all (e.g. wrong port). Also sometimes opening stream fed via UDP is
not interruptible. This patch fixes it.
In fact, there was 'continue' "short-circuit" above interrupt check. Moved
interrupt check to the top of loop.
---
 libavformat/avio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index afaa7e6..cb9334c 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -258,6 +258,8 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
 
     len = 0;
     while (len < size_min) {
+        if (ff_check_interrupt(&h->interrupt_callback))
+            return AVERROR_EXIT;
         ret = transfer_func(h, buf+len, size-len);
         if (ret == AVERROR(EINTR))
             continue;
@@ -274,8 +276,6 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
         if (ret)
            fast_retries = FFMAX(fast_retries, 2);
         len += ret;
-        if (len < size && ff_check_interrupt(&h->interrupt_callback))
-            return AVERROR_EXIT;
     }
     return len;
 }
-- 
1.7.7



More information about the ffmpeg-devel mailing list