[vlc-commits] vout: add a reference count
Rémi Denis-Courmont
git at videolan.org
Sun Mar 17 02:39:13 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 16 12:35:01 2019 +0200| [3e7c471392b6759feba25fe30e6e12ba7342f11b] | committer: Rémi Denis-Courmont
vout: add a reference count
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3e7c471392b6759feba25fe30e6e12ba7342f11b
---
src/video_output/video_output.c | 14 +++++++++++---
src/video_output/vout_internal.h | 4 ++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index c41252936b..8e2700a0c0 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1696,12 +1696,17 @@ void vout_Close(vout_thread_t *vout)
sys->spu = NULL;
vlc_mutex_unlock(&sys->spu_lock);
- vlc_object_delete(vout);
+ vout_Release(vout);
}
void vout_Release(vout_thread_t *vout)
{
- (vlc_object_release)(VLC_OBJECT(vout));
+ vout_thread_sys_t *sys = vout->p;
+
+ if (atomic_fetch_sub_explicit(&sys->refs, 1, memory_order_release))
+ return;
+
+ vlc_object_delete(VLC_OBJECT(vout));
}
static void VoutDestructor(vlc_object_t *object)
@@ -1792,6 +1797,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
/* */
vlc_object_set_destructor(vout, VoutDestructor);
+ atomic_init(&sys->refs, 0);
if (sys->display_cfg.window == NULL) {
spu_Destroy(sys->spu);
@@ -1809,7 +1815,9 @@ vout_thread_t *vout_Create(vlc_object_t *object)
vout_thread_t *vout_Hold(vout_thread_t *vout)
{
- (vlc_object_hold)(VLC_OBJECT(vout));
+ vout_thread_sys_t *sys = vout->p;
+
+ atomic_fetch_add_explicit(&sys->refs, 1, memory_order_relaxed);
return vout;
}
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 1912d855a0..295c35d61c 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -24,6 +24,8 @@
#ifndef LIBVLC_VOUT_INTERNAL_H
#define LIBVLC_VOUT_INTERNAL_H 1
+#include <stdatomic.h>
+
#include <vlc_picture_fifo.h>
#include <vlc_picture_pool.h>
#include <vlc_vout_display.h>
@@ -181,6 +183,8 @@ struct vout_thread_sys_t
picture_pool_t *decoder_pool;
picture_fifo_t *decoder_fifo;
vout_chrono_t render; /**< picture render time estimator */
+
+ atomic_uintptr_t refs;
};
/**
More information about the vlc-commits
mailing list