]> git.sesse.net Git - vlc/commitdiff
The input_items array is private data.
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 5 May 2008 19:17:20 +0000 (22:17 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 5 May 2008 20:34:21 +0000 (23:34 +0300)
Hide it before someone thinks (s)he can use it without locking libvlc.

include/vlc_main.h
src/input/item.c
src/libvlc-common.c
src/libvlc.h

index 76356bcaa00959b70f81ccbc8f47c4144033143c..f4162289c3f77195add798d0bae739fdb744b7e4 100644 (file)
@@ -47,10 +47,6 @@ struct libvlc_int_t
 
     global_stats_t       *p_stats;           ///< Global statistics
 
-    /* There is no real reason to keep a list of items, but not to break
-     * everything, let's keep it */
-    input_item_array_t    input_items;       ///< Array of all created input items
-    int                   i_last_input_id ;  ///< Last id of input item
 
     /* Structure storing the action name / key associations */
     struct hotkey
index 4aed77ba6d53fb34b848b0619e5c5a80f4bb6f01..1432a56c81c2a1a51d683be137c1f7ba947f4c65 100644 (file)
@@ -183,6 +183,7 @@ char *input_ItemGetInfo( input_item_t *p_i,
 static void input_ItemDestroy ( gc_object_t *p_this )
 {
     vlc_object_t *p_obj = (vlc_object_t *)p_this->p_destructor_arg;
+    libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
     input_item_t *p_input = (input_item_t *) p_this;
     int i;
 
@@ -190,9 +191,9 @@ static void input_ItemDestroy ( gc_object_t *p_this )
 
     vlc_mutex_lock( &p_obj->p_libvlc->object_lock );
 
-    ARRAY_BSEARCH( p_obj->p_libvlc->input_items,->i_id, int, p_input->i_id, i);
+    ARRAY_BSEARCH( priv->input_items,->i_id, int, p_input->i_id, i);
     if( i != -1 )
-        ARRAY_REMOVE( p_obj->p_libvlc->input_items, i);
+        ARRAY_REMOVE( priv->input_items, i);
 
     vlc_mutex_unlock( &p_obj->p_libvlc->object_lock );
 
@@ -301,14 +302,15 @@ int input_ItemAddInfo( input_item_t *p_i,
 
 input_item_t *__input_ItemGetById( vlc_object_t *p_obj, int i_id )
 {
+    libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
     input_item_t * p_ret = NULL;
     int i;
 
     vlc_mutex_lock( &p_obj->p_libvlc->object_lock );
 
-    ARRAY_BSEARCH( p_obj->p_libvlc->input_items, ->i_id, int, i_id, i);
+    ARRAY_BSEARCH( priv->input_items, ->i_id, int, i_id, i);
     if( i != -1 )
-        p_ret = ARRAY_VAL( p_obj->p_libvlc->input_items, i);
+        p_ret = ARRAY_VAL( priv->input_items, i);
 
     vlc_mutex_unlock( &p_obj->p_libvlc->object_lock );
 
@@ -334,14 +336,16 @@ input_item_t *input_ItemNewWithType( 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);
+
     DECMALLOC_NULL( p_input, input_item_t );
 
     input_ItemInit( p_obj, p_input );
     vlc_gc_init( p_input, input_ItemDestroy, (void *)p_obj );
 
     vlc_mutex_lock( &p_obj->p_libvlc->object_lock );
-    p_input->i_id = ++p_obj->p_libvlc->i_last_input_id;
-    ARRAY_APPEND( p_obj->p_libvlc->input_items, p_input );
+    p_input->i_id = ++priv->i_last_input_id;
+    ARRAY_APPEND( priv->input_items, p_input );
     vlc_mutex_unlock( &p_obj->p_libvlc->object_lock );
 
     p_input->b_fixed_name = false;
index 149b4d73dc988c042a45e746d910c76c5dc07433..1c81ca79e5a41bdba3614c34fe29febff0885a55 100644 (file)
@@ -720,8 +720,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     priv->p_stats_computer = NULL;
 
     /* Init the array that holds every input item */
-    ARRAY_INIT( p_libvlc->input_items );
-    p_libvlc->i_last_input_id = 0;
+    ARRAY_INIT( priv->input_items );
+    priv->i_last_input_id = 0;
 
     /*
      * Initialize hotkey handling
@@ -1003,13 +1003,13 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
 #endif
 
     bool b_clean = true;
-    FOREACH_ARRAY( input_item_t *p_del, p_libvlc->input_items )
+    FOREACH_ARRAY( input_item_t *p_del, priv->input_items )
         msg_Err( p_libvlc, "input item %p has not been deleted properly: refcount %d, name %s",
             p_del, p_del->i_gc_refcount, p_del->psz_name ? p_del->psz_name : "(null)" );
         b_clean = false;
     FOREACH_END();
     assert( b_clean );
-    ARRAY_RESET( p_libvlc->input_items );
+    ARRAY_RESET( priv->input_items );
 
     msg_Dbg( p_libvlc, "removing stats" );
     vlc_mutex_destroy( &p_libvlc->p_stats->lock );
index a359e525b2d05d5162a548c333699aead9379449..c6c2917a31fb6497b252b7bdb3e4d52abaf2ef66 100644 (file)
@@ -212,6 +212,11 @@ typedef struct libvlc_priv_t
     vlc_mutex_t        config_lock; ///< config file lock
     char *             psz_configfile;   ///< location of config file
 
+    /* There is no real reason to keep a list of items, but not to break
+     * everything, let's keep it */
+    input_item_array_t input_items; ///< Array of all created input items
+    int                i_last_input_id ; ///< Last id of input item
+
     /* Messages */
     msg_bank_t         msg_bank;    ///< The message bank
     int                i_verbose;   ///< info messages