avcodec: Make av_register_hwaccel() and avcodec_register() thread safe
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
a9bbf59be7
commit
8738d94274
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "libavutil/atomic.h"
|
||||||
#include "libavutil/attributes.h"
|
#include "libavutil/attributes.h"
|
||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
@ -161,10 +162,9 @@ av_cold void avcodec_register(AVCodec *codec)
|
|||||||
AVCodec **p;
|
AVCodec **p;
|
||||||
avcodec_init();
|
avcodec_init();
|
||||||
p = &first_avcodec;
|
p = &first_avcodec;
|
||||||
while (*p != NULL)
|
|
||||||
p = &(*p)->next;
|
|
||||||
*p = codec;
|
|
||||||
codec->next = NULL;
|
codec->next = NULL;
|
||||||
|
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
|
||||||
|
p = &(*p)->next;
|
||||||
|
|
||||||
if (codec->init_static_data)
|
if (codec->init_static_data)
|
||||||
codec->init_static_data(codec);
|
codec->init_static_data(codec);
|
||||||
@ -2991,10 +2991,9 @@ static AVHWAccel *first_hwaccel = NULL;
|
|||||||
void av_register_hwaccel(AVHWAccel *hwaccel)
|
void av_register_hwaccel(AVHWAccel *hwaccel)
|
||||||
{
|
{
|
||||||
AVHWAccel **p = &first_hwaccel;
|
AVHWAccel **p = &first_hwaccel;
|
||||||
while (*p)
|
|
||||||
p = &(*p)->next;
|
|
||||||
*p = hwaccel;
|
|
||||||
hwaccel->next = NULL;
|
hwaccel->next = NULL;
|
||||||
|
while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
|
||||||
|
p = &(*p)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
|
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user