[vlc-devel] [PATCH v3 06/10] core: use refcounter helper for vt_utils

Romain Vimont rom1v at videolabs.io
Tue Jul 3 08:47:57 CEST 2018


---
 modules/codec/vt_utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
index 1c62d7d3cfc..6c915d802f9 100644
--- a/modules/codec/vt_utils.c
+++ b/modules/codec/vt_utils.c
@@ -22,7 +22,7 @@
 # include "config.h"
 #endif
 
-#include <stdatomic.h>
+#include <vlc_atomic.h>
 
 #include "vt_utils.h"
 
@@ -48,7 +48,7 @@ struct cvpxpic_ctx
     CVPixelBufferRef cvpx;
     unsigned nb_fields;
 
-    atomic_uint ref_count;
+    vlc_atomic_rc_t rc;
     void (*on_released_cb)(CVPixelBufferRef, void *, unsigned);
     void *on_released_data;
 };
@@ -58,7 +58,7 @@ cvpxpic_destroy_cb(picture_context_t *opaque)
 {
     struct cvpxpic_ctx *ctx = (struct cvpxpic_ctx *)opaque;
 
-    if (atomic_fetch_sub(&ctx->ref_count, 1) == 1)
+    if (vlc_atomic_rc_dec(&ctx->rc))
     {
         CFRelease(ctx->cvpx);
         if (ctx->on_released_cb)
@@ -71,7 +71,7 @@ static picture_context_t *
 cvpxpic_copy_cb(struct picture_context_t *opaque)
 {
     struct cvpxpic_ctx *ctx = (struct cvpxpic_ctx *)opaque;
-    atomic_fetch_add(&ctx->ref_count, 1);
+    vlc_atomic_rc_inc(&ctx->rc);
     return opaque;
 }
 
-- 
2.18.0



More information about the vlc-devel mailing list