MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / retry_transfer_wrapper

Function retry_transfer_wrapper

libavformat/avio.c:504–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502
503
504static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
505 const uint8_t *cbuf,
506 int size, int size_min,
507 int read)
508{
509 int ret, len;
510 int fast_retries = 5;
511 int64_t wait_since = 0;
512
513 len = 0;
514 while (len < size_min) {
515 if (ff_check_interrupt(&h->interrupt_callback))
516 return AVERROR_EXIT;
517 ret = read ? h->prot->url_read (h, buf + len, size - len):
518 h->prot->url_write(h, cbuf + len, size - len);
519 if (ret == AVERROR(EINTR))
520 continue;
521 if (h->flags & AVIO_FLAG_NONBLOCK)
522 return ret;
523 if (ret == AVERROR(EAGAIN)) {
524 ret = 0;
525 if (fast_retries) {
526 fast_retries--;
527 } else {
528 if (h->rw_timeout) {
529 if (!wait_since)
530 wait_since = av_gettime_relative();
531 else if (av_gettime_relative() > wait_since + h->rw_timeout)
532 return AVERROR(EIO);
533 }
534 av_usleep(1000);
535 }
536 } else if (ret == AVERROR_EOF)
537 return (len > 0) ? len : AVERROR_EOF;
538 else if (ret < 0)
539 return ret;
540 if (ret) {
541 fast_retries = FFMAX(fast_retries, 2);
542 wait_since = 0;
543 }
544 len += ret;
545 }
546 return len;
547}
548
549int ffurl_read2(void *urlcontext, uint8_t *buf, int size)
550{

Callers 3

ffurl_read2Function · 0.85
ffurl_read_completeFunction · 0.85
ffurl_write2Function · 0.85

Calls 3

ff_check_interruptFunction · 0.85
av_gettime_relativeFunction · 0.85
av_usleepFunction · 0.85

Tested by

no test coverage detected