History

avcodec/allcodecs: make avcodec_register_all thread safe

use ff_thread_once

Muhammad Faiz committed 9 years ago

Commit e85e8401 parent a6b11801 file · +9 −7Browse files

Showing the changes to libavcodec/allcodecs.c (1 of 1 file). Show all

Unified · Split

libavcodec/allcodecs.c+9−7
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 */
2626
2727 #include "config.h"
28+#include "libavutil/thread.h"
2829 #include "avcodec.h"
2930 #include "version.h"
3031
@@ -58,14 +59,8 @@ · 27 unmodified lines
5859 av_register_codec_parser(&ff_##x##_parser); \
5960 }
6061
61−void avcodec_register_all(void)
62+static void register_all(void)
6263 {
63− static int initialized;
64−
65− if (initialized)
66− return;
67− initialized = 1;
68−
6964 /* hardware accelerators */
7065 REGISTER_HWACCEL(H263_VAAPI, h263_vaapi);
7166 REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);
@@ -718,3 +713,10 @@ void avcodec_register_all(void) · 646 unmodified lines
718713 REGISTER_PARSER(VP9, vp9);
719714 REGISTER_PARSER(XMA, xma);
720715 }
716+
717+void avcodec_register_all(void)
718+{
719+ static AVOnce control = AV_ONCE_INIT;
720+
721+ ff_thread_once(&control, register_all);
722+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t