diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-29 03:24:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-29 03:32:57 +0200 |
commit | 08f6fdc3e4bbda3837417fb20656165756e6ea87 (patch) | |
tree | eec7b92781d4cf41d69ba965a14f07ca958d559c /libavcodec/parser.c | |
parent | 8738d94274ba0144eb07137cc401cf9476b4a77c (diff) | |
download | ffmpeg-08f6fdc3e4bbda3837417fb20656165756e6ea87.tar.gz |
avcodec/parser: Make av_register_codec_parser() thread safe
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/parser.c')
-rw-r--r-- | libavcodec/parser.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/parser.c b/libavcodec/parser.c index f7cb5cfa67..500bbb8f54 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -23,6 +23,7 @@ #include <string.h> #include "parser.h" +#include "libavutil/atomic.h" #include "libavutil/mem.h" static AVCodecParser *av_first_parser = NULL; @@ -34,8 +35,9 @@ AVCodecParser* av_parser_next(AVCodecParser *p){ void av_register_codec_parser(AVCodecParser *parser) { - parser->next = av_first_parser; - av_first_parser = parser; + do { + parser->next = av_first_parser; + } while (parser->next != avpriv_atomic_ptr_cas((void * volatile *)&av_first_parser, parser->next, parser)); } AVCodecParserContext *av_parser_init(int codec_id) |