diff options
author | François Revol <revol@free.fr> | 2007-02-13 18:26:14 +0000 |
---|---|---|
committer | François Revol <revol@free.fr> | 2007-02-13 18:26:14 +0000 |
commit | 8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4 (patch) | |
tree | 551ead2b59bdc4b1855fb60d6c2ce6a2c7787f15 /libavformat/tcp.c | |
parent | bcdf0d269748e2059ffa789033cd6e41739891fc (diff) | |
download | ffmpeg-8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4.tar.gz |
This fixes error handling for BeOS, removing the need for some ifdefs.
AVERROR_ defines are moved to avcodec.h as they are needed in there as well. Feel free to move that to avutil/common.h.
Bumped up avcodec/format version numbers as though it's binary compatible we will want to rebuild apps as error values changed.
Please from now on use return AVERROR(EFOO) instead of the ugly return -EFOO in your code.
This also removes the need for berrno.h.
Originally committed as revision 7965 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/tcp.c')
-rw-r--r-- | libavformat/tcp.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c index be8a4bb0bb..fa9e13587f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -62,7 +62,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) s = av_malloc(sizeof(TCPContext)); if (!s) - return -ENOMEM; + return AVERROR(ENOMEM); h->priv_data = s; if (port <= 0 || port >= 65536) @@ -90,7 +90,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) /* wait until we are connected or until abort */ for(;;) { if (url_interrupt_cb()) { - ret = -EINTR; + ret = AVERROR(EINTR); goto fail1; } fd_max = fd; @@ -130,7 +130,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) for (;;) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&rfds); FD_SET(s->fd, &rfds); @@ -141,11 +141,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) len = recv(s->fd, buf, size, 0); if (len < 0) { if (errno != EINTR && errno != EAGAIN) -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif + return AVERROR(errno); } else return len; } else if (ret < 0) { return -1; @@ -163,7 +159,7 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size) size1 = size; while (size > 0) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); @@ -173,13 +169,8 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size) if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { - if (errno != EINTR && errno != EAGAIN) { -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif - } + if (errno != EINTR && errno != EAGAIN) + return AVERROR(errno); continue; } size -= len; |