[FFmpeg-devel] [PATCH 2/2] lavf: replace ETIMEDOUT by AVERROR_TIMEOUT

Michael Niedermayer michaelni at gmx.at
Tue Sep 4 17:29:51 CEST 2012


ETIMEDOUT is not available on all systems and defining it in an internal
header to something does not help external applications interpreting the
error code. Thus its better we use our own error code, that can be used
everywhere.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/avio.c    |    2 +-
 libavformat/network.c |    2 +-
 libavformat/rtsp.c    |    2 +-
 libavformat/rtspdec.c |    2 +-
 libavformat/tcp.c     |    4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 6ed63f4..4c545d8 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -272,7 +272,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
                     if (!wait_since)
                         wait_since = av_gettime();
                     else if (av_gettime() > wait_since + h->rw_timeout)
-                        return AVERROR(ETIMEDOUT);
+                        return AVERROR_TIMEOUT;
                 }
                 av_usleep(1000);
             }
diff --git a/libavformat/network.c b/libavformat/network.c
index 0e79cae..4bbb2fb 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -169,7 +169,7 @@ int ff_neterrno(void)
     case WSAEPROTONOSUPPORT:
         return AVERROR(EPROTONOSUPPORT);
     case WSAETIMEDOUT:
-        return AVERROR(ETIMEDOUT);
+        return AVERROR_TIMEOUT;
     case WSAECONNREFUSED:
         return AVERROR(ECONNREFUSED);
     case WSAEINPROGRESS:
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d64644d..8cfbedd 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1765,7 +1765,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
             }
 #endif
         } else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
-            return AVERROR(ETIMEDOUT);
+            return AVERROR_TIMEOUT;
         } else if (n < 0 && errno != EINTR)
             return AVERROR(errno);
     }
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 856be56..1cf7674 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -837,7 +837,7 @@ retry:
 
     ret = ff_rtsp_fetch_packet(s, pkt);
     if (ret < 0) {
-        if (ret == AVERROR(ETIMEDOUT) && !rt->packets) {
+        if (ret == AVERROR_TIMEOUT && !rt->packets) {
             if (rt->lower_transport == RTSP_LOWER_TRANSPORT_UDP &&
                 rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_TCP)) {
                 RTSPMessageHeader reply1, *reply = &reply1;
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 8cd217b..261f371 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -107,7 +107,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
         }
         ret = poll(&lp, 1, listen_timeout >= 0 ? listen_timeout : -1);
         if (ret <= 0) {
-            ret = AVERROR(ETIMEDOUT);
+            ret = AVERROR_TIMEOUT;
             goto fail1;
         }
         fd1 = accept(fd, NULL, NULL);
@@ -149,7 +149,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
                 break;
         }
         if (ret <= 0) {
-            ret = AVERROR(ETIMEDOUT);
+            ret = AVERROR_TIMEOUT;
             goto fail;
         }
         /* test error */
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list