[FFmpeg-cvslog] avfilter/avfilter: Make avfilter_register() thread safe

Michael Niedermayer git at videolan.org
Fri Jun 28 12:48:43 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Jun 28 12:39:26 2013 +0200| [2236456715767a297166040c8f7fa10cb980ed35] | committer: Michael Niedermayer

avfilter/avfilter: Make avfilter_register() thread safe

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2236456715767a297166040c8f7fa10cb980ed35
---

 libavfilter/avfilter.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9e3977c..c3228cd 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -19,6 +19,7 @@
  * 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/channel_layout.h"
@@ -465,11 +466,11 @@ int avfilter_register(AVFilter *filter)
                     || (!input->start_frame && !input->end_frame));
     }
 
-    while (*f)
-        f = &(*f)->next;
-    *f = filter;
     filter->next = NULL;
 
+    while(avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
+        f = &(*f)->next;
+
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list