diff options
author | James Almer <jamrial@gmail.com> | 2018-01-04 21:15:21 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-01-05 19:18:34 +0300 |
commit | 167e659b289f6c2236c905ee7b8c50857457c858 (patch) | |
tree | 3bc49d337317f1a6928042e4712dbb011b13ce54 /libavfilter/avfilter.c | |
parent | 57960b1f2800e59a46de2b03f7b37ef6ef1c1e52 (diff) |
avfilter: use a mutex instead of atomics in avfilter_register()
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index b98b32bacb..ff7df672fd 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/atomic.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/buffer.h" @@ -33,6 +32,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/rational.h" #include "libavutil/samplefmt.h" +#include "libavutil/thread.h" #define FF_INTERNAL_FIELDS 1 #include "framequeue.h" @@ -590,19 +590,26 @@ const AVFilter *avfilter_get_by_name(const char *name) return NULL; } +static AVMutex filter_register_mutex = AV_MUTEX_INITIALIZER; + int avfilter_register(AVFilter *filter) { - AVFilter **f = last_filter; + AVFilter **f; /* the filter must select generic or internal exclusively */ av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != AVFILTER_FLAG_SUPPORT_TIMELINE); - filter->next = NULL; + ff_mutex_lock(&filter_register_mutex); + f = last_filter; - while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter)) + while (*f) f = &(*f)->next; + *f = filter; + filter->next = NULL; last_filter = &filter->next; + ff_mutex_unlock(&filter_register_mutex); + return 0; } |