[FFmpeg-cvslog] avcodec/parser: use a mutex instead of atomics in av_register_codec_parser()
James Almer
git at videolan.org
Fri Jan 5 02:57:24 EET 2018
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Jan 4 15:11:32 2018 -0300| [d36335bda5e5eff317240c098337cbfc57906897] | committer: James Almer
avcodec/parser: use a mutex instead of atomics in av_register_codec_parser()
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d36335bda5e5eff317240c098337cbfc57906897
---
libavcodec/parser.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 670680ea7c..747ea2ee8a 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -25,9 +25,9 @@
#include <string.h>
#include "libavutil/avassert.h"
-#include "libavutil/atomic.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
+#include "libavutil/thread.h"
#include "internal.h"
#include "parser.h"
@@ -42,11 +42,14 @@ AVCodecParser *av_parser_next(const AVCodecParser *p)
return av_first_parser;
}
+static AVMutex parser_register_mutex = AV_MUTEX_INITIALIZER;
+
void av_register_codec_parser(AVCodecParser *parser)
{
- do {
- parser->next = av_first_parser;
- } while (parser->next != avpriv_atomic_ptr_cas((void * volatile *)&av_first_parser, parser->next, parser));
+ ff_mutex_lock(&parser_register_mutex);
+ parser->next = av_first_parser;
+ av_first_parser = parser;
+ ff_mutex_unlock(&parser_register_mutex);
}
AVCodecParserContext *av_parser_init(int codec_id)
More information about the ffmpeg-cvslog
mailing list