[vlc-commits] vout: use vlc_atomic_rc_t

Quentin Chateau git at videolan.org
Thu Mar 12 16:30:03 CET 2020


vlc | branch: master | Quentin Chateau <quentin.chateau at deepskycorp.com> | Fri Feb 21 15:14:35 2020 +0100| [f1b76bde7fccbceaa778be57e99691e3589e028f] | committer: Thomas Guillem

vout: use vlc_atomic_rc_t

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f1b76bde7fccbceaa778be57e99691e3589e028f
---

 src/video_output/video_output.c  | 8 +++-----
 src/video_output/vout_internal.h | 5 ++---
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a711d302af..0b3d1cac14 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1829,7 +1829,7 @@ void vout_Release(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
 
-    if (atomic_fetch_sub_explicit(&sys->refs, 1, memory_order_release))
+    if (!vlc_atomic_rc_dec(&sys->rc))
         return;
 
     if (sys->dummy)
@@ -1869,6 +1869,7 @@ static vout_thread_t *vout_CreateCommon(vlc_object_t *object)
     vout_CreateVars(vout);
 
     vout_thread_sys_t *sys = (vout_thread_sys_t *)&vout[1];
+    vlc_atomic_rc_init(&sys->rc);
 
     vout->p = sys;
     return vout;
@@ -1954,9 +1955,6 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     /* Arbitrary initial time */
     vout_chrono_Init(&sys->render, 5, VLC_TICK_FROM_MS(10));
 
-    /* */
-    atomic_init(&sys->refs, 0);
-
     if (var_InheritBool(vout, "video-wallpaper"))
         vout_window_SetState(sys->display_cfg.window, VOUT_WINDOW_STATE_BELOW);
     else if (var_InheritBool(vout, "video-on-top"))
@@ -1969,7 +1967,7 @@ vout_thread_t *vout_Hold(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
 
-    atomic_fetch_add_explicit(&sys->refs, 1, memory_order_relaxed);
+    vlc_atomic_rc_inc(&sys->rc);
     return vout;
 }
 
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index ae2ce3823b..fdc92bfa45 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -24,8 +24,7 @@
 #ifndef LIBVLC_VOUT_INTERNAL_H
 #define LIBVLC_VOUT_INTERNAL_H 1
 
-#include <stdatomic.h>
-
+#include <vlc_atomic.h>
 #include <vlc_picture_fifo.h>
 #include <vlc_picture_pool.h>
 #include <vlc_vout_display.h>
@@ -184,7 +183,7 @@ struct vout_thread_sys_t
     picture_fifo_t  *decoder_fifo;
     vout_chrono_t   render;           /**< picture render time estimator */
 
-    atomic_uintptr_t refs;
+    vlc_atomic_rc_t rc;
 };
 
 /**



More information about the vlc-commits mailing list