[FFmpeg-cvslog] avformat/allformats: Making av_register_all() thread-safe.

Vivekanand git at videolan.org
Fri Aug 26 15:40:58 EEST 2016


ffmpeg | branch: release/2.8 | Vivekanand <sendtovivekanand at gmail.com> | Thu Apr  7 16:34:23 2016 +0530| [5af0ada4427140fc7d7abbd175ecad91433d155d] | committer: Michael Niedermayer

avformat/allformats: Making av_register_all() thread-safe.

When multiple threads tries to call av_register_all(), the first thread sets
initialized to 1 and do the register process. At the same time, other thread might
also call av_register_all(), which returns immediately because initialized is set to 1
(even when it has not completed registering codecs). We can avoid this problem
if we set initialised to 1 while exiting from function.

Github: Closes #196
(cherry picked from commit b092ee701f4d0ef2b8a4171cd38101d1ee9a1034)

Conflicts:

	libavformat/allformats.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5af0ada4427140fc7d7abbd175ecad91433d155d
---

 libavformat/allformats.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0a24ac7..bf3c724 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -54,7 +54,6 @@ void av_register_all(void)
 
     if (initialized)
         return;
-    initialized = 1;
 
     avcodec_register_all();
 
@@ -402,4 +401,6 @@ void av_register_all(void)
     REGISTER_PROTOCOL(LIBRTMPTE,        librtmpte);
     REGISTER_PROTOCOL(LIBSSH,           libssh);
     REGISTER_PROTOCOL(LIBSMBCLIENT,     libsmbclient);
+
+    initialized = 1;
 }



More information about the ffmpeg-cvslog mailing list