You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/parser: use a mutex instead of atomics in av_register_codec_parser()
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -25,9 +25,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/atomic.h"
|
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
|
#include "libavutil/thread.h"
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
@@ -42,11 +42,14 @@ AVCodecParser *av_parser_next(const AVCodecParser *p)
|
|||||||
return av_first_parser;
|
return av_first_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AVMutex parser_register_mutex = AV_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
void av_register_codec_parser(AVCodecParser *parser)
|
void av_register_codec_parser(AVCodecParser *parser)
|
||||||
{
|
{
|
||||||
do {
|
ff_mutex_lock(&parser_register_mutex);
|
||||||
parser->next = av_first_parser;
|
parser->next = av_first_parser;
|
||||||
} while (parser->next != avpriv_atomic_ptr_cas((void * volatile *)&av_first_parser, parser->next, parser));
|
av_first_parser = parser;
|
||||||
|
ff_mutex_unlock(&parser_register_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodecParserContext *av_parser_init(int codec_id)
|
AVCodecParserContext *av_parser_init(int codec_id)
|
||||||
|
Reference in New Issue
Block a user