@@ -123,8 +123,8 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
int err;
#if CONFIG_NETWORK
- if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
- return AVERROR(EIO);
+ if (up->flags & URL_PROTOCOL_FLAG_NETWORK && (err=ff_network_init())<0)
+ return err;
#endif
if ((flags & AVIO_FLAG_READ) && !up->url_read) {
av_log(NULL, AV_LOG_ERROR,
@@ -59,11 +59,10 @@ int ff_network_init(void)
{
#if HAVE_WINSOCK2_H
WSADATA wsaData;
-
- if (WSAStartup(MAKEWORD(1,1), &wsaData))
- return 0;
+ return ff_neterrno2(WSAStartup(MAKEWORD(1,1), &wsaData));
+#else
+ return 0;
#endif
- return 1;
}
int ff_network_wait_fd(int fd, int write)
@@ -1740,8 +1740,8 @@ int ff_rtsp_connect(AVFormatContext *s)
return AVERROR(EINVAL);
}
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((err = ff_network_init())<0)
+ return err;
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = s->iformat ? DEFAULT_REORDERING_DELAY : 0;
@@ -2395,8 +2395,8 @@ static int sdp_read_header(AVFormatContext *s)
char url[MAX_URL_SIZE];
AVBPrint bp;
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((err = ff_network_init())<0)
+ return err;
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = DEFAULT_REORDERING_DELAY;
@@ -2522,8 +2522,8 @@ static int rtp_read_header(AVFormatContext *s)
AVBPrint sdp;
AVDictionary *opts = NULL;
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((ret = ff_network_init())<0)
+ return ret;
opts = map_to_opts(rt);
ret = ffurl_open_whitelist(&in, s->url, AVIO_FLAG_READ,
@@ -663,8 +663,8 @@ static int rtsp_listen(AVFormatContext *s)
int ret;
enum RTSPMethod methodcode;
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((ret = ff_network_init())<0)
+ return ret;
/* extract hostname and port */
av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host),
@@ -70,8 +70,8 @@ static int sap_read_header(AVFormatContext *s)
int port;
int ret, i;
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((ret = ff_network_init())<0)
+ return ret;
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port,
path, sizeof(path), s->url);
@@ -80,8 +80,8 @@ static int sap_write_header(AVFormatContext *s)
int udp_fd;
AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0);
- if (!ff_network_init())
- return AVERROR(EIO);
+ if ((ret = ff_network_init())<0)
+ return ret;
/* extract hostname and port */
av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &base_port,