[vlc-devel] [PATCH v2 02/10] core: use refcounter helper for input items

Romain Vimont rom1v at videolabs.io
Mon Jul 2 16:49:34 CEST 2018


---
 src/input/item.c | 6 +++---
 src/input/item.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/input/item.c b/src/input/item.c
index 6789f73caa5..8e846425b4b 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -471,7 +471,7 @@ input_item_t *input_item_Hold( input_item_t *p_item )
 {
     input_item_owner_t *owner = item_owner(p_item);
 
-    atomic_fetch_add( &owner->refs, 1 );
+    vlc_atomic_rc_inc( &owner->rc );
     return p_item;
 }
 
@@ -479,7 +479,7 @@ void input_item_Release( input_item_t *p_item )
 {
     input_item_owner_t *owner = item_owner(p_item);
 
-    if( atomic_fetch_sub(&owner->refs, 1) != 1 )
+    if( !vlc_atomic_rc_dec( &owner->rc ) )
         return;
 
     vlc_event_manager_fini( &p_item->event_manager );
@@ -1060,7 +1060,7 @@ input_item_NewExt( const char *psz_uri, const char *psz_name,
     if( unlikely(owner == NULL) )
         return NULL;
 
-    atomic_init( &owner->refs, 1 );
+    vlc_atomic_rc_init( &owner->rc );
 
     input_item_t *p_input = &owner->item;
     vlc_event_manager_t * p_em = &p_input->event_manager;
diff --git a/src/input/item.h b/src/input/item.h
index dce1dfc0584..bce49777f8d 100644
--- a/src/input/item.h
+++ b/src/input/item.h
@@ -25,7 +25,7 @@
 #define LIBVLC_INPUT_ITEM_H 1
 
 #include "input_interface.h"
-#include <stdatomic.h>
+#include <vlc_atomic.h>
 
 void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error );
 void input_item_UpdateTracksInfo( input_item_t *item, const es_format_t *fmt );
@@ -34,7 +34,7 @@ bool input_item_ShouldPreparseSubItems( input_item_t *p_i );
 typedef struct input_item_owner
 {
     input_item_t item;
-    atomic_uint refs;
+    vlc_atomic_rc_t rc;
 } input_item_owner_t;
 
 # define item_owner(item) ((struct input_item_owner *)(item))
-- 
2.18.0



More information about the vlc-devel mailing list