[FFmpeg-devel] [PATCH 2/2] Revert "Non-blocking protocol: core wrapper functions"

Luca Barbato lu_zero
Sat Mar 12 02:03:25 CET 2011


This reverts commit 90441276e4f661c6aec5e4d2c5718cde1ff1946d.
---
 libavformat/avio.c |   32 +++++++++++++-------------------
 libavformat/avio.h |    1 +
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4ab1b6b..28dd62c 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -213,21 +213,24 @@ int url_open(URLContext **puc, const char *filename, int flags)
     return ret;
 }
 
-static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size, int size_min,
+int url_read(URLContext *h, unsigned char *buf, int size)
+{
+    int ret;
+    if (h->flags & URL_WRONLY)
+        return AVERROR(EIO);
+    ret = h->prot->url_read(h, buf, size);
+    return ret;
+}
+
+static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int size,
                                          int (*transfer_func)(URLContext *h, unsigned char *buf, int size))
 {
     int ret, len;
     int fast_retries = 5;
 
     len = 0;
-    while (len < size_min) {
-        if (url_interrupt_cb())
-            return AVERROR(EINTR);
+    while (len < size) {
         ret = transfer_func(h, buf+len, size-len);
-        if (ret == AVERROR(EINTR))
-            continue;
-        if (h->flags & URL_FLAG_NONBLOCK)
-            return ret;
         if (ret == AVERROR(EAGAIN)) {
             ret = 0;
             if (fast_retries)
@@ -243,18 +246,9 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
     return len;
 }
 
-int url_read(URLContext *h, unsigned char *buf, int size)
-{
-    if (h->flags & URL_WRONLY)
-        return AVERROR(EIO);
-    return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
-}
-
 int url_read_complete(URLContext *h, unsigned char *buf, int size)
 {
-    if (h->flags & URL_WRONLY)
-        return AVERROR(EIO);
-    return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
+    return retry_transfer_wrapper(h, buf, size, url_read);
 }
 
 int url_write(URLContext *h, const unsigned char *buf, int size)
@@ -265,7 +259,7 @@ int url_write(URLContext *h, const unsigned char *buf, int size)
     if (h->max_packet_size && size > h->max_packet_size)
         return AVERROR(EIO);
 
-    return retry_transfer_wrapper(h, buf, size, size, h->prot->url_write);
+    return retry_transfer_wrapper(h, buf, size, h->prot->url_write);
 }
 
 int64_t url_seek(URLContext *h, int64_t pos, int whence)
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 8bae263..3bba611 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -151,6 +151,7 @@ int url_read(URLContext *h, unsigned char *buf, int size);
 /**
  * Read as many bytes as possible (up to size), calling the
  * read function multiple times if necessary.
+ * Will also retry if the read function returns AVERROR(EAGAIN).
  * This makes special short-read handling in applications
  * unnecessary, if the return value is < size then it is
  * certain there was either an error or the end of file was reached.
-- 
1.7.4.1




More information about the ffmpeg-devel mailing list