[vlc-devel] [PATCH 2/2] vout: use vlc_atomic_rc_t
quentin.chateau at deepskycorp.com
quentin.chateau at deepskycorp.com
Fri Feb 21 15:14:35 CET 2020
From: Quentin Chateau <quentin.chateau at deepskycorp.com>
---
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 edda78d731..03a8770764 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1834,7 +1834,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)
@@ -1879,6 +1879,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;
@@ -1964,9 +1965,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"))
@@ -1979,7 +1977,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;
};
/**
--
2.17.1
More information about the vlc-devel
mailing list