summaryrefslogtreecommitdiff
path: root/libavformat/network.h
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-02-19 19:14:11 +0100
committerRonald S. Bultje <rsbultje@gmail.com>2011-02-23 07:21:31 -0500
commit28c4741a6617a4c1d2490cb13fc70ae4c9c472da (patch)
tree492c04df564f16ba9fd634c29eb4ea69154dab87 /libavformat/network.h
parent8f935b9271052be8f97d655081b94b68b6c23bfb (diff)
libavformat: Remove FF_NETERRNO()
Map EAGAIN and EINTR from ff_neterrno to the normal AVERROR() error codes. Provide fallback definitions of other errno.h network errors, mapping them to the corresponding winsock errors. This eases catching these error codes in common code, without having to distinguish between FF_NETERRNO(EAGAIN) and AVERROR(EAGAIN). This fixes roundup issue 2614, unbreaking blocking network IO on windows. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavformat/network.h')
-rw-r--r--libavformat/network.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/libavformat/network.h b/libavformat/network.h
index d6aee93121..58a8e80e72 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -27,9 +27,21 @@
#include <winsock2.h>
#include <ws2tcpip.h>
-#define ff_neterrno() (-WSAGetLastError())
-#define FF_NETERROR(err) (-WSA##err)
-#define WSAEAGAIN WSAEWOULDBLOCK
+#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#define ETIMEDOUT WSAETIMEDOUT
+#define ECONNREFUSED WSAECONNREFUSED
+#define EINPROGRESS WSAEINPROGRESS
+
+static inline int ff_neterrno() {
+ int err = WSAGetLastError();
+ switch (err) {
+ case WSAEWOULDBLOCK:
+ return AVERROR(EAGAIN);
+ case WSAEINTR:
+ return AVERROR(EINTR);
+ }
+ return -err;
+}
#else
#include <sys/types.h>
#include <sys/socket.h>
@@ -37,7 +49,6 @@
#include <netdb.h>
#define ff_neterrno() AVERROR(errno)
-#define FF_NETERROR(err) AVERROR(err)
#endif
#if HAVE_ARPA_INET_H