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
25 */25 */
26 26
27#include "config.h"27#include "config.h"
28#include "libavutil/thread.h"
28#include "avcodec.h"29#include "avcodec.h"
29#include "version.h"30#include "version.h"
30 31
@@ -58,14 +59,8 @@ · 27 unmodified lines
58 av_register_codec_parser(&ff_##x##_parser); \59 av_register_codec_parser(&ff_##x##_parser); \
59 }60 }
60 61
61void avcodec_register_all(void)62static void register_all(void)
62{63{
63 static int initialized;
64
65 if (initialized)
66 return;
67 initialized = 1;
68
69 /* hardware accelerators */64 /* hardware accelerators */
70 REGISTER_HWACCEL(H263_VAAPI, h263_vaapi);65 REGISTER_HWACCEL(H263_VAAPI, h263_vaapi);
71 REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);66 REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);
@@ -718,3 +713,10 @@ void avcodec_register_all(void) · 646 unmodified lines
718 REGISTER_PARSER(VP9, vp9);713 REGISTER_PARSER(VP9, vp9);
719 REGISTER_PARSER(XMA, xma);714 REGISTER_PARSER(XMA, xma);
720}715}
716
717void 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