[FFmpeg-devel] [PATCH 3/4] lavf/format: simplify I/O registration

Rostislav Pehlivanov atomnuker at gmail.com
Mon Nov 27 06:30:20 EET 2017


Same as previous commit, unneded use of atomics.

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
---
 libavformat/format.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavformat/format.c b/libavformat/format.c
index 38ca2a3465..6ac7349ec5 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/atomic.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
@@ -62,9 +61,11 @@ void av_register_input_format(AVInputFormat *format)
 {
     AVInputFormat **p = last_iformat;
 
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
+    /* Iterate through the list until the last entry has been reached */
+    while (p != &format->next && !format->next) {
+        *p = format;
+        p  = &(format)->next;
+    }
 
     if (!format->next)
         last_iformat = &format->next;
@@ -74,9 +75,11 @@ void av_register_output_format(AVOutputFormat *format)
 {
     AVOutputFormat **p = last_oformat;
 
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
+    /* Iterate through the list until the last entry has been reached */
+    while (p != &format->next && !format->next) {
+        *p = format;
+        p  = &(format)->next;
+    }
 
     if (!format->next)
         last_oformat = &format->next;
-- 
2.15.0.417.g466bffb3ac



More information about the ffmpeg-devel mailing list