diff options
author | Muhammad Faiz <mfcc64@gmail.com> | 2017-03-07 11:51:12 +0300 |
---|---|---|
committer | Muhammad Faiz <mfcc64@gmail.com> | 2017-03-07 16:34:44 +0300 |
commit | e85e8408802dc3a474e6a610867df8e57c768339 (patch) | |
tree | dcfe6623933a91b9f87011932aca9cb850e2c026 /libavcodec/allcodecs.c | |
parent | a6b1180e390925c0ceb78fd223fd18f8c1e39c94 (diff) |
avcodec/allcodecs: make avcodec_register_all thread safe
use ff_thread_once
Suggested-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libavcodec/allcodecs.c')
-rw-r--r-- | libavcodec/allcodecs.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index a265ce5728..074efd463f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -25,6 +25,7 @@ */ #include "config.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "version.h" @@ -58,14 +59,8 @@ av_register_codec_parser(&ff_##x##_parser); \ } -void avcodec_register_all(void) +static void register_all(void) { - static int initialized; - - if (initialized) - return; - initialized = 1; - /* hardware accelerators */ REGISTER_HWACCEL(H263_VAAPI, h263_vaapi); REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox); @@ -718,3 +713,10 @@ void avcodec_register_all(void) REGISTER_PARSER(VP9, vp9); REGISTER_PARSER(XMA, xma); } + +void avcodec_register_all(void) +{ + static AVOnce control = AV_ONCE_INIT; + + ff_thread_once(&control, register_all); +} |