[FFmpeg-cvslog] avformat: make av_register_*put_format() thread safe
Michael Niedermayer
git at videolan.org
Sat Jun 29 03:52:59 CEST 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jun 29 03:44:15 2013 +0200| [53fd1ab26bec7d045d168590bf49de722e2a601c] | committer: Michael Niedermayer
avformat: make av_register_*put_format() thread safe
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53fd1ab26bec7d045d168590bf49de722e2a601c
---
libavformat/format.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/libavformat/format.c b/libavformat/format.c
index c1be859..ac9100b 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)
More information about the ffmpeg-cvslog
mailing list