From b092ee701f4d0ef2b8a4171cd38101d1ee9a1034 Mon Sep 17 00:00:00 2001 From: Vivekanand Date: Thu, 7 Apr 2016 16:16:23 +0530 Subject: 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 --- libavformat/allformats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavformat/allformats.c') diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0a38793289..ddf540ca03 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -47,7 +47,6 @@ void av_register_all(void) if (initialized) return; - initialized = 1; avcodec_register_all(); @@ -371,4 +370,6 @@ void av_register_all(void) REGISTER_DEMUXER (LIBGME, libgme); REGISTER_DEMUXER (LIBMODPLUG, libmodplug); REGISTER_MUXDEMUX(LIBNUT, libnut); + + initialized = 1; } -- cgit v1.2.3