From ce145690b6a53dd9d5134c6d4a5c6d401bc69514 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Mon, 7 Nov 2011 13:57:33 +0200
Subject: [PATCH] avformat: Warn about using network functions without calling
 avformat_network_init
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is to make developers aware of the fact that they will
start using the new init function at some point.

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 libavformat/network.c | 7 +++++++
 libavformat/network.h | 1 +
 libavformat/utils.c   | 1 +
 3 files changed, 9 insertions(+)

diff --git a/libavformat/network.c b/libavformat/network.c
index d84dcaf2194..f8403aef838 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -119,8 +119,15 @@ void ff_tls_deinit(void)
     avpriv_unlock_avformat();
 }
 
+int ff_network_inited_globally;
+
 int ff_network_init(void)
 {
+    if (!ff_network_inited_globally)
+        av_log(NULL, AV_LOG_WARNING, "Using network protocols without global "
+                                     "network initialization. Please use "
+                                     "avformat_network_init(), this will "
+                                     "become mandatory later.\n");
 #if HAVE_WINSOCK2_H
     WSADATA wsaData;
     if (WSAStartup(MAKEWORD(1,1), &wsaData))
diff --git a/libavformat/network.h b/libavformat/network.h
index df79f4598f5..72d01d29868 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -56,6 +56,7 @@ int ff_neterrno(void);
 
 int ff_socket_nonblock(int socket, int enable);
 
+extern int ff_network_inited_globally;
 int ff_network_init(void);
 void ff_network_close(void);
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8d0ae050d88..cb472c925a7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3967,6 +3967,7 @@ int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_co
 int avformat_network_init(void)
 {
 #if CONFIG_NETWORK
+    ff_network_inited_globally = 1;
     int ret;
     if ((ret = ff_network_init()) < 0)
         return ret;
-- 
GitLab