[vlc-commits] core: use refcounter helper for input resources

Romain Vimont git at videolan.org
Mon Jul 9 09:22:17 CEST 2018


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Jul  5 10:30:50 2018 +0200| [2d9c4249f5bff56c342f41f82a94d77099fde1d6] | committer: Steve Lhomme

core: use refcounter helper for input resources

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

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

 src/input/resource.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index 8b88bb5d63..b1a8675dc3 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -28,10 +28,10 @@
 # include "config.h"
 #endif
 
-#include <stdatomic.h>
 #include <assert.h>
 
 #include <vlc_common.h>
+#include <vlc_atomic.h>
 #include <vlc_vout.h>
 #include <vlc_spu.h>
 #include <vlc_aout.h>
@@ -45,7 +45,7 @@
 
 struct input_resource_t
 {
-    atomic_uint    refs;
+    vlc_atomic_rc_t rc;
 
     vlc_object_t   *p_parent;
 
@@ -422,7 +422,7 @@ input_resource_t *input_resource_New( vlc_object_t *p_parent )
     if( !p_resource )
         return NULL;
 
-    atomic_init( &p_resource->refs, 1 );
+    vlc_atomic_rc_init( &p_resource->rc );
     p_resource->p_parent = p_parent;
     vlc_mutex_init( &p_resource->lock );
     vlc_mutex_init( &p_resource->lock_hold );
@@ -431,7 +431,7 @@ input_resource_t *input_resource_New( vlc_object_t *p_parent )
 
 void input_resource_Release( input_resource_t *p_resource )
 {
-    if( atomic_fetch_sub( &p_resource->refs, 1 ) != 1 )
+    if( !vlc_atomic_rc_dec( &p_resource->rc ) )
         return;
 
     DestroySout( p_resource );
@@ -446,7 +446,7 @@ void input_resource_Release( input_resource_t *p_resource )
 
 input_resource_t *input_resource_Hold( input_resource_t *p_resource )
 {
-    atomic_fetch_add( &p_resource->refs, 1 );
+    vlc_atomic_rc_inc( &p_resource->rc );
     return p_resource;
 }
 



More information about the vlc-commits mailing list