Revision f1d2b572

View differences:

libavformat/avio.c
19 19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
 */
21 21

  
22
/* needed for usleep() */
23
#define _XOPEN_SOURCE 600
24
#include <unistd.h>
22 25
#include "libavutil/avstring.h"
23 26
#include "libavcodec/opt.h"
24 27
#include "os_support.h"
......
152 155
int url_read_complete(URLContext *h, unsigned char *buf, int size)
153 156
{
154 157
    int ret, len;
158
    int fast_retries = 5;
155 159

  
156 160
    len = 0;
157 161
    while (len < size) {
158 162
        ret = url_read(h, buf+len, size-len);
159 163
        if (ret == AVERROR(EAGAIN)) {
160 164
            ret = 0;
165
            if (fast_retries)
166
                fast_retries--;
167
            else
168
                usleep(1000);
161 169
        } else if (ret < 1)
162 170
            return ret < 0 ? ret : len;
171
        if (ret)
172
           fast_retries = FFMAX(fast_retries, 2);
163 173
        len += ret;
164 174
    }
165 175
    return len;

Also available in: Unified diff