Commit 04a4af73 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

The input_items array is private data.

Hide it before someone thinks (s)he can use it without locking libvlc.
parent f3cf5c6e
...@@ -47,10 +47,6 @@ struct libvlc_int_t ...@@ -47,10 +47,6 @@ struct libvlc_int_t
global_stats_t *p_stats; ///< Global statistics 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 */ /* Structure storing the action name / key associations */
struct hotkey struct hotkey
......
...@@ -183,6 +183,7 @@ char *input_ItemGetInfo( input_item_t *p_i, ...@@ -183,6 +183,7 @@ char *input_ItemGetInfo( input_item_t *p_i,
static void input_ItemDestroy ( gc_object_t *p_this ) static void input_ItemDestroy ( gc_object_t *p_this )
{ {
vlc_object_t *p_obj = (vlc_object_t *)p_this->p_destructor_arg; 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; input_item_t *p_input = (input_item_t *) p_this;
int i; int i;
...@@ -190,9 +191,9 @@ static void input_ItemDestroy ( gc_object_t *p_this ) ...@@ -190,9 +191,9 @@ static void input_ItemDestroy ( gc_object_t *p_this )
vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); 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 ) 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 ); vlc_mutex_unlock( &p_obj->p_libvlc->object_lock );
...@@ -301,14 +302,15 @@ int input_ItemAddInfo( input_item_t *p_i, ...@@ -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 ) 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; input_item_t * p_ret = NULL;
int i; int i;
vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); 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 ) 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 ); 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, ...@@ -334,14 +336,16 @@ input_item_t *input_ItemNewWithType( vlc_object_t *p_obj, const char *psz_uri,
mtime_t i_duration, mtime_t i_duration,
int i_type ) int i_type )
{ {
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
DECMALLOC_NULL( p_input, input_item_t ); DECMALLOC_NULL( p_input, input_item_t );
input_ItemInit( p_obj, p_input ); input_ItemInit( p_obj, p_input );
vlc_gc_init( p_input, input_ItemDestroy, (void *)p_obj ); vlc_gc_init( p_input, input_ItemDestroy, (void *)p_obj );
vlc_mutex_lock( &p_obj->p_libvlc->object_lock ); vlc_mutex_lock( &p_obj->p_libvlc->object_lock );
p_input->i_id = ++p_obj->p_libvlc->i_last_input_id; p_input->i_id = ++priv->i_last_input_id;
ARRAY_APPEND( p_obj->p_libvlc->input_items, p_input ); ARRAY_APPEND( priv->input_items, p_input );
vlc_mutex_unlock( &p_obj->p_libvlc->object_lock ); vlc_mutex_unlock( &p_obj->p_libvlc->object_lock );
p_input->b_fixed_name = false; p_input->b_fixed_name = false;
......
...@@ -720,8 +720,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -720,8 +720,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
priv->p_stats_computer = NULL; priv->p_stats_computer = NULL;
/* Init the array that holds every input item */ /* Init the array that holds every input item */
ARRAY_INIT( p_libvlc->input_items ); ARRAY_INIT( priv->input_items );
p_libvlc->i_last_input_id = 0; priv->i_last_input_id = 0;
/* /*
* Initialize hotkey handling * Initialize hotkey handling
...@@ -1003,13 +1003,13 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -1003,13 +1003,13 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
#endif #endif
bool b_clean = true; 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", 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)" ); p_del, p_del->i_gc_refcount, p_del->psz_name ? p_del->psz_name : "(null)" );
b_clean = false; b_clean = false;
FOREACH_END(); FOREACH_END();
assert( b_clean ); assert( b_clean );
ARRAY_RESET( p_libvlc->input_items ); ARRAY_RESET( priv->input_items );
msg_Dbg( p_libvlc, "removing stats" ); msg_Dbg( p_libvlc, "removing stats" );
vlc_mutex_destroy( &p_libvlc->p_stats->lock ); vlc_mutex_destroy( &p_libvlc->p_stats->lock );
......
...@@ -212,6 +212,11 @@ typedef struct libvlc_priv_t ...@@ -212,6 +212,11 @@ typedef struct libvlc_priv_t
vlc_mutex_t config_lock; ///< config file lock vlc_mutex_t config_lock; ///< config file lock
char * psz_configfile; ///< location of config file 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 */ /* Messages */
msg_bank_t msg_bank; ///< The message bank msg_bank_t msg_bank; ///< The message bank
int i_verbose; ///< info messages int i_verbose; ///< info messages
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment