[vlc-commits] Use vlc_atomic_t for input item ID
Rémi Denis-Courmont
git at videolan.org
Sun Jul 10 17:53:29 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 10 17:42:37 2011 +0300| [dca6b1f8920c547e8267293a3d41ebe25daa6b1c] | committer: Rémi Denis-Courmont
Use vlc_atomic_t for input item ID
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dca6b1f8920c547e8267293a3d41ebe25daa6b1c
---
src/input/item.c | 8 +++-----
src/libvlc.c | 2 --
src/libvlc.h | 1 -
3 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/input/item.c b/src/input/item.c
index ccd7013..f8f1937 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -31,6 +31,7 @@
#include "vlc_playlist.h"
#include "vlc_interface.h"
#include <vlc_charset.h>
+#include <vlc_atomic.h>
#include "item.h"
#include "info.h"
@@ -844,8 +845,7 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
mtime_t i_duration,
int i_type )
{
- libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
- static vlc_mutex_t input_id_lock = VLC_STATIC_MUTEX;
+ static vlc_atomic_t last_input_id = VLC_ATOMIC_INIT(0);
input_item_t* p_input = malloc( sizeof(input_item_t ) );
if( !p_input )
@@ -854,9 +854,7 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
input_item_Init( p_obj, p_input );
vlc_gc_init( p_input, input_item_Destroy );
- vlc_mutex_lock( &input_id_lock );
- p_input->i_id = ++priv->i_last_input_id;
- vlc_mutex_unlock( &input_id_lock );
+ p_input->i_id = vlc_atomic_inc(&last_input_id);
p_input->b_fixed_name = false;
diff --git a/src/libvlc.c b/src/libvlc.c
index 3747032..8a4fb23 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -770,8 +770,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
priv->i_timers = 0;
priv->pp_timers = NULL;
- priv->i_last_input_id = 0; /* Not very safe, should be removed */
-
/*
* Initialize hotkey handling
*/
diff --git a/src/libvlc.h b/src/libvlc.h
index c702cc0..e6c0a6b 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -182,7 +182,6 @@ typedef struct libvlc_priv_t
{
libvlc_int_t public_data;
- int i_last_input_id ; ///< Last id of input item
bool playlist_active;
/* Messages */
More information about the vlc-commits
mailing list