diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-29 03:44:15 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-29 03:46:10 +0200 |
commit | 53fd1ab26bec7d045d168590bf49de722e2a601c (patch) | |
tree | e24abb40cc0b716980c61c285f0837caa5730413 /libavformat/format.c | |
parent | b36b5edb8fea33ebcacc0b77ce412372dd9f79e4 (diff) | |
download | ffmpeg-53fd1ab26bec7d045d168590bf49de722e2a601c.tar.gz |
avformat: make av_register_*put_format() thread safe
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/format.c')
-rw-r--r-- | libavformat/format.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/format.c b/libavformat/format.c index c1be85983a..ac9100b604 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -21,6 +21,7 @@ #include "avformat.h" #include "internal.h" +#include "libavutil/atomic.h" #include "libavutil/avstring.h" /** @@ -52,22 +53,18 @@ void av_register_input_format(AVInputFormat *format) { AVInputFormat **p = &first_iformat; - while (*p != NULL) - p = &(*p)->next; - - *p = format; format->next = NULL; + while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + p = &(*p)->next; } void av_register_output_format(AVOutputFormat *format) { AVOutputFormat **p = &first_oformat; - while (*p != NULL) - p = &(*p)->next; - - *p = format; format->next = NULL; + while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + p = &(*p)->next; } int av_match_ext(const char *filename, const char *extensions) |