Permalink
Browse files

Remove avformat_network_init() not called warning.

Make sure avformat_network_init() is called before ffurl_open is ever called.
  • Loading branch information...
1 parent 5a8db30 commit dd4eab189a67dd2951eb22259b94b8bc500d89a9 @jyavenard jyavenard committed Jun 1, 2012
@@ -1622,7 +1622,9 @@ bool HLSRingBuffer::TestForHTTPLiveStreaming(QString &filename)
av_register_all();
avcodeclock->unlock();
URLContext *context;
+
// Do a peek on the URL to test the format
+ RingBuffer::AVFormatInitNetwork();
int ret = ffurl_open(&context, filename.toAscii(),
AVIO_FLAG_READ, NULL, NULL);
if (ret >= 0)
@@ -46,6 +46,11 @@ QMutex RingBuffer::subExtLock;
QStringList RingBuffer::subExt;
QStringList RingBuffer::subExtNoCheck;
+extern "C" {
+#include "libavformat/avformat.h"
+}
+bool RingBuffer::gAVformat_net_initialised = false;
+
/*
Locking relations:
rwlock->poslock->rbrlock->rbwlock
@@ -92,7 +97,7 @@ QStringList RingBuffer::subExtNoCheck;
* a pre-buffering thread, otherwise Start(void)
* will start a pre-buffering thread.
* \param timeout_ms if < 0, then we will not open the file.
- * Otherwise it's how long to try opening
+ * Otherwise it's how long to try opening
* the file after the first failure in
* milliseconds before giving up.
*/
@@ -807,7 +812,7 @@ void RingBuffer::run(void)
(now.tv_usec - lastread.tv_usec) / 1000;
readtimeavg = (readtimeavg * 9 + readinterval) / 10;
- if (readtimeavg < 150 &&
+ if (readtimeavg < 150 &&
(uint)readblocksize < (BUFFER_SIZE_MINIMUM >>2) &&
readblocksize >= CHUNK /* low_buffers */)
{
@@ -950,7 +955,7 @@ void RingBuffer::run(void)
generalWait.wakeAll();
rwlock.unlock();
usleep(5 * 1000);
- rwlock.lockForRead();
+ rwlock.lockForRead();
}
else
{
@@ -966,7 +971,7 @@ void RingBuffer::run(void)
generalWait.wakeAll();
rwlock.unlock();
usleep(5 * 1000);
- rwlock.lockForRead();
+ rwlock.lockForRead();
}
}
}
@@ -1643,4 +1648,15 @@ BDRingBuffer *RingBuffer::BD(void)
return dynamic_cast<BDRingBuffer*>(this);
}
+void RingBuffer::AVFormatInitNetwork(void)
+{
+ QMutexLocker lock(avcodeclock);
+
+ if (!gAVformat_net_initialised)
+ {
+ avformat_network_init();
+ gAVformat_net_initialised = true;
+ }
+}
+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
@@ -152,6 +152,8 @@ class MTV_PUBLIC RingBuffer : protected MThread
static const int kDefaultOpenTimeout;
static const int kLiveTVOpenTimeout;
+ static void AVFormatInitNetwork(void);
+
protected:
RingBuffer(RingBufferType rbtype);
@@ -253,6 +255,9 @@ class MTV_PUBLIC RingBuffer : protected MThread
static QMutex subExtLock;
static QStringList subExt;
static QStringList subExtNoCheck;
+
+ private:
+ static bool gAVformat_net_initialised;
};
#endif // _RINGBUFFER_H_
@@ -41,6 +41,7 @@ bool StreamingRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
avcodeclock->lock();
av_register_all();
avcodeclock->unlock();
+ RingBuffer::AVFormatInitNetwork();
rwlock.lockForWrite();

0 comments on commit dd4eab1

Please sign in to comment.