Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-29 05:11:48 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-06-29 05:28:58 +0400
commit8738d94274ba0144eb07137cc401cf9476b4a77c (patch)
tree5682463f6e580dc9ac49e555b2e467492acc0455 /libavcodec/utils.c
parenta9bbf59be73264ed63b08b67024cd04720dd1f43 (diff)
avcodec: Make av_register_hwaccel() and avcodec_register() thread safe
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e0819f4515..e659cc546c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -26,6 +26,7 @@
*/
#include "config.h"
+#include "libavutil/atomic.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
@@ -161,10 +162,9 @@ av_cold void avcodec_register(AVCodec *codec)
AVCodec **p;
avcodec_init();
p = &first_avcodec;
- while (*p != NULL)
- p = &(*p)->next;
- *p = codec;
codec->next = NULL;
+ while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
+ p = &(*p)->next;
if (codec->init_static_data)
codec->init_static_data(codec);
@@ -2991,10 +2991,9 @@ static AVHWAccel *first_hwaccel = NULL;
void av_register_hwaccel(AVHWAccel *hwaccel)
{
AVHWAccel **p = &first_hwaccel;
- while (*p)
- p = &(*p)->next;
- *p = hwaccel;
hwaccel->next = NULL;
+ while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
+ p = &(*p)->next;
}
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)