[2/2] avio: Only do implicit network initialization for network protocols

Message ID 1325708997-57711-2-git-send-email-martin@martin.st
State Committed
Commit acb074301c8612dfd5f135a0513bbe93a2dc51d1
Headers show

Commit Message

Martin Storsjö Jan. 4, 2012, 8:29 p.m.
The implicit network initialization is set to be removed in the
future, but is kept for compatibility. By not doing the implicit
initialization for non-network protocols, we avoid the warning
about avformat_network_init() not being called for these, where
it really doesn't make much sense.
---
 libavformat/avio.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Comments

Anton Khirnov Jan. 5, 2012, 1:39 p.m. | #1
On Wed,  4 Jan 2012 22:29:57 +0200, Martin Storsjö <martin@martin.st> wrote:
> The implicit network initialization is set to be removed in the
> future, but is kept for compatibility. By not doing the implicit
> initialization for non-network protocols, we avoid the warning
> about avformat_network_init() not being called for these, where
> it really doesn't make much sense.
> ---

Both patches look ok.
Luca Barbato Jan. 5, 2012, 2:17 p.m. | #2
On 05/01/12 14:39, Anton Khirnov wrote:
>
> On Wed,  4 Jan 2012 22:29:57 +0200, Martin Storsjö<martin@martin.st>  wrote:
>> The implicit network initialization is set to be removed in the
>> future, but is kept for compatibility. By not doing the implicit
>> initialization for non-network protocols, we avoid the warning
>> about avformat_network_init() not being called for these, where
>> it really doesn't make much sense.
>> ---
>
> Both patches look ok.
>
+1

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4750a9d..ee4dfb6 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -129,7 +129,7 @@  static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
     int err;
 
 #if CONFIG_NETWORK
-    if (!ff_network_init())
+    if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
         return AVERROR(EIO);
 #endif
     uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
@@ -159,7 +159,8 @@  static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
  fail:
     *puc = NULL;
 #if CONFIG_NETWORK
-    ff_network_close();
+    if (up->flags & URL_PROTOCOL_FLAG_NETWORK)
+        ff_network_close();
 #endif
     return err;
 }
@@ -380,7 +381,8 @@  int ffurl_close(URLContext *h)
     if (h->is_connected && h->prot->url_close)
         ret = h->prot->url_close(h);
 #if CONFIG_NETWORK
-    ff_network_close();
+    if (h->prot->flags & URL_PROTOCOL_FLAG_NETWORK)
+        ff_network_close();
 #endif
     if (h->prot->priv_data_size) {
         if (h->prot->priv_data_class)