[FFmpeg-devel] [RFC] url_write()
Reimar Döffinger
Reimar.Doeffinger
Tue Oct 5 23:43:13 CEST 2010
On Tue, Oct 05, 2010 at 10:04:43PM +0200, Michael Niedermayer wrote:
> int url_write(URLContext *h, const unsigned char *buf, int size)
> {
> - int ret;
> + int len= 0;
> + int fast_retries= 5;
> if (!(h->flags & (URL_WRONLY | URL_RDWR)))
> return AVERROR(EIO);
> /* avoid sending too big packets */
> if (h->max_packet_size && size > h->max_packet_size)
> return AVERROR(EIO);
> - ret = h->prot->url_write(h, buf, size);
> - return ret;
> +
> + while(len<size){
> + int ret= h->prot->url_write(h, buf+len, size-len);
> + if (ret == AVERROR(EAGAIN)) {
> + ret= 0;
> + if (fast_retries){
> + fast_retries--;
> + }else
> + usleep(1000);
> + } else if (ret < 1)
> + return ret < 0 ? ret : len;
> + if (ret)
> + fast_retries = FFMAX(fast_retries, 2);
> + len += ret;
> + }
> + return len;
Very strange space-placement, particularly since the
"url_read_complete" does not have it.
Obviously due to some clean up, but I guess both should be
identical.
How about a
static inline int retry_transfer_wrapper(URLContext *h, const unsigned char *buf, int size,
int (*transfer_func)(URLContext *h, const unsigned char *buf, int size))
And using it for both instead of duplicating it?
More information about the ffmpeg-devel
mailing list