Commit 514c0dbf authored by reimar's avatar reimar

Make url_read_complete retry on EAGAIN and return how much data it read

if it reached EOF, making it useful in more cases.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21393 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent ba25c2ba
...@@ -156,8 +156,10 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size) ...@@ -156,8 +156,10 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size)
len = 0; len = 0;
while (len < size) { while (len < size) {
ret = url_read(h, buf+len, size-len); ret = url_read(h, buf+len, size-len);
if (ret < 1) if (ret == AVERROR(EAGAIN)) {
return ret; ret = 0;
} else if (ret < 1)
return ret < 0 ? ret : len;
len += ret; len += ret;
} }
return len; return len;
......
...@@ -69,6 +69,14 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, ...@@ -69,6 +69,14 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up,
const char *filename, int flags); const char *filename, int flags);
int url_open(URLContext **h, const char *filename, int flags); int url_open(URLContext **h, const char *filename, int flags);
int url_read(URLContext *h, unsigned char *buf, int size); 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.
*/
int url_read_complete(URLContext *h, unsigned char *buf, int size); int url_read_complete(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size); int url_write(URLContext *h, unsigned char *buf, int size);
int64_t url_seek(URLContext *h, int64_t pos, int whence); int64_t url_seek(URLContext *h, int64_t pos, int whence);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment