use ff_thread_once
Showing the changes to libavcodec/allcodecs.c (1 of 1 file). Show all
Unified · Split
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #include "config.h" |
| 28 | +#include "libavutil/thread.h" | |
| 28 | 29 | #include "avcodec.h" |
| 29 | 30 | #include "version.h" |
| 30 | 31 | |
| @@ -58,14 +59,8 @@ · 27 unmodified lines | ||
| 58 | 59 | av_register_codec_parser(&ff_##x##_parser); \ |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | −void avcodec_register_all(void) | |
| 62 | +static void register_all(void) | |
| 62 | 63 | { |
| 63 | − static int initialized; | |
| 64 | − | |
| 65 | − if (initialized) | |
| 66 | − return; | |
| 67 | − initialized = 1; | |
| 68 | − | |
| 69 | 64 | /* hardware accelerators */ |
| 70 | 65 | REGISTER_HWACCEL(H263_VAAPI, h263_vaapi); |
| 71 | 66 | REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox); |
| @@ -718,3 +713,10 @@ void avcodec_register_all(void) · 646 unmodified lines | ||
| 718 | 713 | REGISTER_PARSER(VP9, vp9); |
| 719 | 714 | REGISTER_PARSER(XMA, xma); |
| 720 | 715 | } |
| 716 | + | |
| 717 | +void avcodec_register_all(void) | |
| 718 | +{ | |
| 719 | + static AVOnce control = AV_ONCE_INIT; | |
| 720 | + | |
| 721 | + ff_thread_once(&control, register_all); | |
| 722 | +} | |